Module:MOS degrees: Difference between revisions
No edit summary |
m Minor change to how duplicate entries (the roots of periods for multi-period mosses) are handled |
||
| Line 53: | Line 53: | ||
-- TODO: separate this into a helper module called "MOS notation" | -- TODO: separate this into a helper module called "MOS notation" | ||
function p.mos_degrees(input_mos, udp, step_ratio) | function p.mos_degrees(input_mos, udp, step_ratio) | ||
local input_mos = input_mos or mos.new( | local input_mos = input_mos or mos.new(6, 2, 2) | ||
local step_ratio = step_ratio or { 2, 1 } | local step_ratio = step_ratio or { 2, 1 } | ||
| Line 173: | Line 173: | ||
-- Find the equave complements for the second genchain, and interpret those | -- Find the equave complements for the second genchain, and interpret those | ||
-- as mosdegrees | -- as mosdegrees. This must come after the ascending genchains so in the case that | ||
-- one pitch is reached in two directions (eg, C# and Db in standard tuning), | |||
-- the one from the ascending chain (the C# in the example) comes first. | |||
for j = 1, periods_per_equave do | for j = 1, periods_per_equave do | ||
local accumulator = 0 | local accumulator = 0 | ||
for i = | |||
-- The start index for the following for loop starts at a note one period up | |||
-- and goes down. However, with a multi-period mos, that same note is the root | |||
-- for the next period, leading to a duplicate entry. To keep that from happening, | |||
-- only start the for loop at 1 if this is the last period. | |||
local start_index = 1 | |||
if j ~= #periods_per_equave then | |||
start_index = start_index + 1 | |||
end | |||
for i = start_index, #des_genchain[j] do | |||
local index = (accumulator % esteps_per_period) + (j - 1) * esteps_per_period + 1 | local index = (accumulator % esteps_per_period) + (j - 1) * esteps_per_period + 1 | ||
| Line 223: | Line 234: | ||
-- Add to degrees | -- Add to degrees | ||
if degrees[index] == "" then | if degrees[index] == "" then | ||
degrees[index] = degrees[index] .. degree_name | degrees[index] = degrees[index] .. degree_name | ||
else | |||
degrees[index] = degrees[index] .. ", " .. degree_name | degrees[index] = degrees[index] .. ", " .. degree_name | ||
end | end | ||