Module:TAMNAMS: Difference between revisions
Added experimental code for handling step patterns that exceed the equave |
m Code readability |
||
| Line 781: | Line 781: | ||
for j = 1, #input_mode_as_step_matrix do | for j = 1, #input_mode_as_step_matrix do | ||
local mode_interval = input_mode_as_step_matrix[j] | local mode_interval = input_mode_as_step_matrix[j] | ||
-- If | -- If j is greater than the number of intervals in the current true | ||
-- corresponding equave-reduced interval | -- mode, then the interval being accessed is an extra-equave | ||
-- interval. Instead of accessing the jth interval (which would lead | |||
-- to a nil error), instead access the corresponding equave-reduced | |||
-- interval, then raise it by the necessary number of equaves. | |||
local true_interval = {} | |||
if j > #current_true_mode then | |||
local current_mossteps = j - 1 | |||
local equave_step_count = mos.equave_step_count(input_mos) | |||
local equave_reduced_interval = current_true_mode[current_mossteps % equave_step_count + 1] | |||
local equave_count = math.floor(current_mossteps / equave_step_count) | |||
local equaves = mos.interval_mul(mos.equave(input_mos), equave_count) | |||
true_interval = mos.interval_add(equave_reduced_interval, equaves) | |||
else | |||
true_interval = current_true_mode[j] | |||
end | end | ||
| Line 818: | Line 827: | ||
-- Produce the list of alterations, if the mode is for a modmos. | -- Produce the list of alterations, if the mode is for a modmos. | ||
local alterations = "" | local alterations = "" | ||
local | local closest_true_mode = true_modes[bright_gens_down_per_period + 1] | ||
if lowest_differences > 0 then | if lowest_differences > 0 then | ||
for i = 1, #input_mode_as_step_matrix do | for i = 1, #input_mode_as_step_matrix do | ||
mode_interval = input_mode_as_step_matrix[i] | mode_interval = input_mode_as_step_matrix[i] | ||
-- If | -- If i is greater than the number of intervals in the current true | ||
-- corresponding equave-reduced interval | -- mode, then the interval being accessed is an extra-equave | ||
-- interval. Instead of accessing the ith interval (which would lead | |||
-- to a nil error), instead access the corresponding equave-reduced | |||
-- interval, then raise it by the necessary number of equaves. | |||
local true_interval = {} | |||
if i > #closest_true_mode then | |||
local current_mossteps = i - 1 | |||
local equave_step_count = mos.equave_step_count(input_mos) | |||
local equave_reduced_interval = closest_true_mode[current_mossteps % equave_step_count + 1] | |||
local equave_count = math.floor(current_mossteps / equave_step_count) | |||
local equaves = mos.interval_mul(mos.equave(input_mos), equave_count) | |||
true_interval = mos.interval_add(equave_reduced_interval, equaves) | |||
else | |||
true_interval = closest_true_mode[i] | |||
end | end | ||
| Line 854: | Line 872: | ||
output_ = output_ .. "LLsLsAs" .. " " .. p.mode_udp("LLsLsAs", mos.new(5,2)) | output_ = output_ .. "LLsLsAs" .. " " .. p.mode_udp("LLsLsAs", mos.new(5,2)) | ||
return p.mode_rotation_udps(" | return p.mode_rotation_udps("sAsLsAs", mos.new(5, 2), "m", false) | ||
--return p.degree_quality({4, -1}, mos.new(5,2), "ABBREV", 'm') | --return p.degree_quality({4, -1}, mos.new(5,2), "ABBREV", 'm') | ||