Module:MOS intro: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Added todo
Ganaram inukshuk (talk | contribs)
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 softest_ancestral_step_ratio = string.format("%d:%d", lg_chunk.nL + lg_chunk.ns, sm_chunk.nL + sm_chunk.ns)
-- Sort ratios by hardness
local hardest_ancestral_step_ratio = string.format("%d:%d", lg_chunk.nL, sm_chunk.nL)
local num1 = lg_chunk.nL + lg_chunk.ns
local den1 = sm_chunk.nL + sm_chunk.ns
-- TODO: Correct this so it goes by hardness; smallest hardness value first
local num2 = lg_chunk.nL
if input_mos.nL > input_mos.ns then
local den2 = sm_chunk.nL
local temp = softest_ancestral_step_ratio
local first_ancestor_step_ratio = ""
softest_ancestral_step_ratio = hardest_ancestral_step_ratio
local second_ancestor_step_ratio = ""
hardest_ancestral_step_ratio = temp
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", softest_ancestral_step_ratio, hardest_ancestral_step_ratio)
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 descendant_type = ""
local descendant_text = ""
if generations == 1 then
if generations == 1 then
descendant_type = string.format("%s is a '''chromatic scale''' of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos))
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_type = string.format("%s is an '''enharmonic scale''' of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos))
descendant_text = string.format("%s is an '''enharmonic scale''' of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos))
else
else
descendant_type = string.format("%s is a descendant scale of [[%s]]", mos.as_string(input_mos), mos.as_string(ancestor_mos))
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_type = descendant_type .. string.format(", produced by such scales with a [[step ratio]] within the range of %s.", step_ratio_range)
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_type = descendant_type .. string.format(", produced by such scales with a [[step ratio]] within the %s range (%s).", named_range, step_ratio_range)
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 descendant_type
return descendant_text
end
end