Module:MOS intro: Difference between revisions
m Fixing up rounding |
Fixed rounding by converting values to strings |
||
| Line 117: | Line 117: | ||
-- How large is the period in cents? Round to 3 decimal places | -- How large is the period in cents? Round to 3 decimal places | ||
local round = 3 | local round = 3 | ||
local equave_rounded = utils._round_dec(equave_in_cents, round) | local equave_rounded = tostring(utils._round_dec(equave_in_cents, round)) | ||
local period_rounded = utils._round_dec(equave_in_cents / n, round) | local period_rounded = tostring(utils._round_dec(equave_in_cents / n, round)) | ||
-- Should step be singular or plural? | -- Should step be singular or plural? | ||
local s_x = "" | local s_x = "" | ||
| Line 137: | Line 137: | ||
sentence = sentence .. string.format(", repeating every [[octave]].") | sentence = sentence .. string.format(", repeating every [[octave]].") | ||
elseif n == 1 and equave_in_cents ~= 1200 then | elseif n == 1 and equave_in_cents ~= 1200 then | ||
sentence = sentence .. string.format(", repeating every interval of [[%s]] (% | sentence = sentence .. string.format(", repeating every interval of [[%s]] (%s¢).", equave_as_ratio, equave_rounded) | ||
elseif n ~= 1 and equave_in_cents == 1200 then | elseif n ~= 1 and equave_in_cents == 1200 then | ||
sentence = sentence .. string.format(", with a [[period]] of %d large step%s and %d small step%s", x, s_x, y, s_y) | sentence = sentence .. string.format(", with a [[period]] of %d large step%s and %d small step%s", x, s_x, y, s_y) | ||
sentence = sentence .. string.format(" that repeats every % | sentence = sentence .. string.format(" that repeats every %s¢, or %s every [[octave]].", period_rounded, repetition) | ||
elseif n ~= 1 and equave_in_cents ~= 1200 then | elseif n ~= 1 and equave_in_cents ~= 1200 then | ||
sentence = sentence .. string.format(", with a [[period]] of %d large step%s and %d small step%s", x, s_x, y, s_y) | sentence = sentence .. string.format(", with a [[period]] of %d large step%s and %d small step%s", x, s_x, y, s_y) | ||
sentence = sentence .. string.format(" that repeats every % | sentence = sentence .. string.format(" that repeats every %s¢, or %s every interval of %s (%s¢).", period_rounded, repetition, equave_as_ratio, equave_rounded) | ||
end | end | ||
| Line 193: | Line 193: | ||
-- Round values | -- Round values | ||
local round = 3 | local round = 3 | ||
local bright_gen_min_r = utils._round_dec(bright_gen_min, round) | local bright_gen_min_r = tostring(utils._round_dec(bright_gen_min, round)) | ||
local bright_gen_max_r = utils._round_dec(bright_gen_max, round) | local bright_gen_max_r = tostring(utils._round_dec(bright_gen_max, round)) | ||
local dark_gen_min_r = utils._round_dec(dark_gen_min, round) | local dark_gen_min_r = tostring(utils._round_dec(dark_gen_min, round)) | ||
local dark_gen_max_r = utils._round_dec(dark_gen_max, round) | local dark_gen_max_r = tostring(utils._round_dec(dark_gen_max, round)) | ||
local sentence = string.format("[[generator|Generating intervals]] that produce this scale range from % | local sentence = string.format("[[generator|Generating intervals]] that produce this scale range from %s¢ to %s¢, or from %s¢ to %s¢.", bright_gen_min_r, bright_gen_max_r, dark_gen_min_r, dark_gen_max_r) | ||
return sentence | return sentence | ||