Module:MOS intro: Difference between revisions
m Added todo |
Fixed logic for step ratio range names |
||
| Line 115: | Line 115: | ||
-- Calculate the range of step ratios the ancestor should have | -- Calculate the range of step ratios the ancestor should have | ||
local | -- Sort ratios by hardness | ||
local | local num1 = lg_chunk.nL + lg_chunk.ns | ||
local den1 = sm_chunk.nL + sm_chunk.ns | |||
local num2 = lg_chunk.nL | |||
local den2 = sm_chunk.nL | |||
local first_ancestor_step_ratio = "" | |||
local second_ancestor_step_ratio = "" | |||
if num1/den1 < num2/den2 then | |||
first_ancestor_step_ratio = string.format("%d:%d", num1, den1) | |||
second_ancestor_step_ratio = string.format("%d:%d", num2, den2) | |||
else | |||
first_ancestor_step_ratio = string.format("%d:%d", num2, den2) | |||
second_ancestor_step_ratio = string.format("%d:%d", num1, den1) | |||
end | end | ||
-- Step ratio range as text | -- Step ratio range as text | ||
local step_ratio_range = string.format("%s to %s", | local step_ratio_range = string.format("%s to %s", first_ancestor_step_ratio, second_ancestor_step_ratio) | ||
-- Step ratio range as a named range | -- Step ratio range as a named range | ||
| Line 160: | Line 165: | ||
end | end | ||
local | local descendant_text = "" | ||
if generations == 1 then | if generations == 1 then | ||
descendant_text = string.format("%s is a '''chromatic scale''' of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos)) | |||
elseif generations == 2 then | elseif generations == 2 then | ||
descendant_text = string.format("%s is an '''enharmonic scale''' of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos)) | |||
else | else | ||
descendant_text = string.format("%s is a descendant scale of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos)) | |||
end | end | ||
if named_range == "" then | if named_range == "" then | ||
descendant_text = descendant_text .. string.format(", produced by such scales with a [[step ratio]] within the range of %s.", step_ratio_range) | |||
else | else | ||
descendant_text = descendant_text .. string.format(", produced by such scales with a [[step ratio]] within the %s range (%s).", named_range, step_ratio_range) | |||
end | end | ||
--return string.format("Lg chunk: %d Ls, %d s's; sm chunk: %d L's, %d s's", lg_chunk.nL, lg_chunk.ns, sm_chunk.nL, sm_chunk.ns) | --return string.format("Lg chunk: %d Ls, %d s's; sm chunk: %d L's, %d s's", lg_chunk.nL, lg_chunk.ns, sm_chunk.nL, sm_chunk.ns) | ||
return | return descendant_text | ||
end | end | ||