Module:TAMNAMS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added experimental code for handling step patterns that exceed the equave
Ganaram inukshuk (talk | contribs)
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]
local true_interval = current_true_mode[j]
-- If a true interval is an extra-equave interval, get the
-- If j is greater than the number of intervals in the current true
-- corresponding equave-reduced interval and add back an equave
-- mode, then the interval being accessed is an extra-equave
if true_interval == nil then
-- interval. Instead of accessing the jth interval (which would lead
true_interval = current_true_mode[(j-1) % mos.equave_step_count(input_mos) + 1]
-- to a nil error), instead access the corresponding equave-reduced
true_interval = mos.interval_add(true_interval, mos.interval_mul(mos.equave(input_mos), math.floor((j-1)/mos.equave_step_count(input_mos))))
-- 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 closest_true_mos_mode = true_modes[bright_gens_down_per_period + 1]
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]
true_interval = closest_mode_as_step_matrix[i]
-- If a true interval is an extra-equave interval, get the
-- If i is greater than the number of intervals in the current true
-- corresponding equave-reduced interval and add back an equave
-- mode, then the interval being accessed is an extra-equave
if true_interval == nil then
-- interval. Instead of accessing the ith interval (which would lead
true_interval = closest_mode_as_step_matrix[(i-1) % mos.equave_step_count(input_mos) + 1]
-- to a nil error), instead access the corresponding equave-reduced
true_interval = mos.interval_add(true_interval, mos.interval_mul(mos.equave(input_mos), math.floor((i-1)/mos.equave_step_count(input_mos))))
-- 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("LLsLLsLLsLL", mos.new(5, 2), "m")
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')