Module:MOS genchain: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
No edit summary
Line 17: Line 17:
p.cell_color_sm_altered_size = "#F8CBAD"
p.cell_color_sm_altered_size = "#F8CBAD"


function p.genchain(input_mos, num_gens)
local input_mos = input_mos or mos.new(5,2)
local num_gens = num_gens or (mos.period_step_count(input_mos) - 1)
local bright_gen = mos.bright_gen(input_mos)
local stacked_gens = mos.unison()
local genchain = { mos.unison() }
local abs_num_gens = math.abs(num_gens)
local sign = num_gens > 0 and 1 or -1
for i = 1, abs_num_gens do
stacked_gens = mos.interval_add(stacked_gens, mos.interval_mul(bright_gen, sign))
table.insert(genchain, stacked_gens)
end
return genchain
end


-- wip; to replace genchain
function p.preprocess_genchain(input_mos)
function p.preprocess_genchain(input_mos)
local input_mos = input_mos or mos.new(5,2)
local input_mos = input_mos or mos.new(5,2)
Line 56: Line 37:
local num_gens = mos.period_step_count(input_mos)
local num_gens = mos.period_step_count(input_mos)
local genchain = p.genchain(input_mos, num_gens)
local genchain = p.preprocess_genchain(input_mos)
local rev_genchain = p.genchain(input_mos, -num_gens)
-- Begin table
-- Begin table
Line 64: Line 44:
-- Generators header cell
-- Generators header cell
result = result .. "! Bright generator count\n"
result = result .. "! Number of bright gens\n"
-- Add a row for the generator counts
-- Add a row for the generator counts
-- Descending genchain
for i = 1, #genchain do
for i = num_gens - 1, 1, -1 do
result = result .. string.format("%s %s", (i == 1 and "|" or " ||"), i - num_gens)
if i == num_gens then
result = result .. string.format("| %s", -i)
else
result = result .. string.format(" || %s", -i)
end
end
-- Ascending genchain
for i = 1, num_gens do
result = result .. string.format(" || %s", i - 1)
end
end
result = result .. "\n"
result = result .. "\n"
Line 85: Line 56:
if period_count == 1 then
if period_count == 1 then
result = result .. "! Degree quality\n"
result = result .. "! Degree quality\n"
for i = num_gens, 1, -1 do
for i = 1, #genchain do
local current_interval = mos.interval_mul(genchain[i], -1)
result = result .. string.format("%s %s", (i == 1 and "|" or " ||"), tamnams.degree_quality(genchain[i], input_mos, "abbrev"))
current_interval = mos.equave_reduce(current_interval, input_mos)
if i == num_gens then
result = result .. string.format("| %s", tamnams.degree_quality(current_interval, input_mos, "abbrev"))
else
result = result .. string.format(" || %s", tamnams.degree_quality(current_interval, input_mos, "abbrev"))
end
end
end
for i = 2, num_gens do
local current_interval = mos.equave_reduce(genchain[i], input_mos)
result = result .. string.format(" || %s", tamnams.degree_quality(current_interval, input_mos, "abbrev"))
end
else
else
for i = 1, period_count do
for i = 1, period_count do