Module:MOS genchain: Difference between revisions
mNo edit summary |
Period scale degrees for negative gen counts are shifted one period up |
||
| Line 38: | Line 38: | ||
function p._mos_genchain(input_mos) | function p._mos_genchain(input_mos) | ||
local input_mos = input_mos or mos.new(6, | local input_mos = input_mos or mos.new(6, 4) | ||
local num_gens = mos.period_step_count(input_mos) | local num_gens = mos.period_step_count(input_mos) | ||
| Line 63: | Line 63: | ||
for i = 1, #genchain do | for i = 1, #genchain do | ||
-- Number of generators | -- Number of generators | ||
result = result .. string.format("| %s", | local num_gens = math.ceil(#genchain/2) - i | ||
result = result .. string.format("| %s", num_gens) | |||
local | local current_interval = genchain[i] | ||
local period_interval = mos.period(input_mos) | local period_interval = mos.period(input_mos) | ||
-- Scale degree (full name) and abbrev | |||
for j = 1, period_count do | for j = 1, period_count do | ||
-- | -- If the scale degree corresponds to the root, say it's both the | ||
-- root and the degree one period up. | |||
result = result .. string.format(" || %s", tamnams.degree_quality( | -- If the scale degree is reached by a negative number of gens, then | ||
result = result .. string.format(" || %s", tamnams.degree_quality( | -- say it's the degree one period up instead. | ||
current_interval = mos.interval_add(current_interval, mos.interval_mul(period_interval, j - 1)) | |||
period_raised_interval = mos.interval_add(current_interval, period_interval) | |||
if num_gens == 0 then | |||
result = result | |||
.. string.format(" || %s<br>%s", tamnams.degree_quality(current_interval, input_mos, "sentence-case"), tamnams.degree_quality(period_raised_interval, input_mos, "sentence-case")) | |||
.. string.format(" || %s<br>%s", tamnams.degree_quality(current_interval, input_mos, "abbrev") , tamnams.degree_quality(period_raised_interval, input_mos, "abbrev") ) | |||
elseif num_gens < 0 and mos.interval_step_count(current_interval) % mos.period_step_count(input_mos) == 0 then | |||
result = result | |||
.. string.format(" || %s", tamnams.degree_quality(period_raised_interval, input_mos, "sentence-case")) | |||
.. string.format(" || %s", tamnams.degree_quality(period_raised_interval, input_mos, "abbrev")) | |||
else | |||
result = result | |||
.. string.format(" || %s", tamnams.degree_quality(current_interval, input_mos, "sentence-case")) | |||
.. string.format(" || %s", tamnams.degree_quality(current_interval, input_mos, "abbrev")) | |||
end | |||
end | end | ||