Module:MOS in EDO: Difference between revisions
Corrected valid generator range: 0 exclusive to period exclusive |
Added comments; corrected code regarding degenerate mosses (mosses that become edos) |
||
| Line 167: | Line 167: | ||
-- Are the args for the starting mos valid? | -- Are the args for the starting mos valid? | ||
-- The number of steps in the generator must be between 1 and the number of steps in the period | -- The number of steps in the generator must be between 1 (inclusive) and the number of steps in the period (exclusive) | ||
local starting_mos_valid = gen_in_edosteps >= 1 and gen_in_edosteps < period_in_edosteps | local starting_mos_valid = gen_in_edosteps >= 1 and gen_in_edosteps <= period_in_edosteps | ||
-- Calculate the starting mos | -- Calculate the starting mos | ||
| Line 177: | Line 177: | ||
end | end | ||
-- Create table, starting with headers | |||
local result = string.format('{| class="wikitable"\n') | local result = string.format('{| class="wikitable"\n') | ||
result = result .. string.format('|-\n') | result = result .. string.format('|-\n') | ||
| Line 187: | Line 188: | ||
end | end | ||
-- Add the step pattern for successive mosses until the pattern becomes that for an edo | |||
while current_scale ~= nil and starting_mos_valid do | while current_scale ~= nil and starting_mos_valid do | ||
-- Add the step sizes | |||
result = result .. string.format('|-\n') | result = result .. string.format('|-\n') | ||
for i = 1, #current_scale do | for i = 1, #current_scale do | ||
| Line 198: | Line 201: | ||
end | end | ||
-- Add the scale sig | |||
-- If the mos is an edo, say it's an edo instead | |||
local scale_sig = p.mos_step_pattern_to_scale_sig(current_scale) | local scale_sig = p.mos_step_pattern_to_scale_sig(current_scale) | ||
local current_step_sizes = p.calculate_step_sizes(current_scale) | |||
result = result .. string.format("| %iedo\n", edo / | local step_ratio_gcd = utils._gcd(current_step_sizes["L"], current_step_sizes["s"]) | ||
local reduced_large_step_size = current_step_sizes["L"] / step_ratio_gcd | |||
local reduced_small_step_size = current_step_sizes["s"] / step_ratio_gcd | |||
if reduced_large_step_size == reduced_small_step_size then | |||
result = result .. string.format("| %iedo\n", edo / step_ratio_gcd) | |||
else | else | ||
result = result .. string.format("| [[%s]]\n", scale_sig) | result = result .. string.format("| [[%s]]\n", scale_sig) | ||
end | end | ||
-- Add the step ratio | |||
result = result .. string.format("| %s:%s\n", current_step_sizes["L"] / step_ratio_gcd, current_step_sizes["s"] / step_ratio_gcd) | result = result .. string.format("| %s:%s\n", current_step_sizes["L"] / step_ratio_gcd, current_step_sizes["s"] / step_ratio_gcd) | ||
-- Add the tamnams name | |||
local tamnams_name = mos.tamnams_name[scale_sig] | local tamnams_name = mos.tamnams_name[scale_sig] | ||
if tamnams_name ~= nil then | if tamnams_name ~= nil then | ||
| Line 216: | Line 225: | ||
end | end | ||
-- Add the temperament name, if there is one | |||
if show_temperament then | if show_temperament then | ||
local current_step_count = #current_scale | local current_step_count = #current_scale | ||
| Line 221: | Line 231: | ||
end | end | ||
-- Produce the next scale in the sequence | |||
current_scale = p.calculate_next_mos_step_pattern(current_scale) | current_scale = p.calculate_next_mos_step_pattern(current_scale) | ||
end | end | ||
| Line 229: | Line 240: | ||
end | end | ||
-- Function to be called by a template | |||
function p.edo_mos_step_patterns_frame(frame) | function p.edo_mos_step_patterns_frame(frame) | ||