Module:MOS genchain: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
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,2)
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", math.ceil(#genchain/2) - i)
local num_gens = math.ceil(#genchain/2) - i
result = result .. string.format("| %s", num_gens)
local current_period_reduced_interval = genchain[i]
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
-- Scale degree (full name) and abbrev
-- If the scale degree corresponds to the root, say it's both the
current_period_reduced_interval = mos.interval_add(current_period_reduced_interval, mos.interval_mul(period_interval, j - 1))
-- root and the degree one period up.
result = result .. string.format(" || %s", tamnams.degree_quality(current_period_reduced_interval, input_mos, "sentence-case"))
-- If the scale degree is reached by a negative number of gens, then
result = result .. string.format(" || %s", tamnams.degree_quality(current_period_reduced_interval, input_mos, "abbrev"))
-- 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