Module:MOS degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
Trying to bring back color-coded rows that mimics a piano
Ganaram inukshuk (talk | contribs)
Fixing function calls to the gamut module
Line 38: Line 38:
-- How far these extend is dependent on UDP
-- How far these extend is dependent on UDP
-- 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, step_ratio, generators_up)
function p.mos_degrees(input_mos, step_ratio, udp)
local input_mos = input_mos or mos.new(5, 2, 2)
local input_mos = input_mos or mos.new(5, 2, 2)
local step_ratio = step_ratio or { 2, 1 }
local step_ratio = step_ratio or { 2, 1 }
Line 47: Line 47:
local mossteps_per_period = mossteps_per_equave / periods_per_equave
local mossteps_per_period = mossteps_per_equave / periods_per_equave
-- The default generators_up value corresponds to the brightest mode,
-- The default UDP corresponds to the brightest mode
-- unless the mos is 5L 2s, then it's the 2nd-brightest mode
-- If it's 5L 2s, default to the second-brightest mode
local generators_up_default = mossteps_per_equave - periods_per_equave
local udp_default = { mossteps_per_equave - periods_per_equave, 0 }
if scale_sig == "5L 2s" then
if scale_sig == "5L 2s" then
generators_up_default = 5
udp_default = { 5, 1 }
end
end
local generators_up = generators_up or generators_up_default
local udp_parsed = udp or udp_default
local generators_up = udp_parsed[1]
-- Reconstruct the UDP up|dp (u times p pipe d times p)
local generators_down = udp_parsed[2]
-- The generators_up corresponds to up and is given to us, so generators_down should
-- be reconstructed to correspond to dp; dividing either generators_up or generators_down
-- by the number of periods will give the number of generators per period (u and d by
-- themselves)
local generators_down = mossteps_per_equave - generators_up - periods_per_equave
-- How long is the inital genchain for notes without accidentals?
-- How long is the inital genchain for notes without accidentals?
Line 256: Line 251:
local scale_sig = mos.as_string(input_mos)
local scale_sig = mos.as_string(input_mos)
-- The default generators_up value corresponds to the brightest mode,
-- The default UDP corresponds to the brightest mode
-- unless the mos is 5L 2s, then it's the 2nd-brightest mode
-- If it's 5L 2s, default to the second-brightest mode
local generators_up = mossteps_per_equave - periods_per_equave
local udp = { mossteps_per_equave - periods_per_equave, 0 }
if scale_sig == "5L 2s" then
if scale_sig == "5L 2s" then
generators_up = 5
udp = { 5, 1 }
end
end
-- If a value was entered, override the default value
if string.len(frame.args['UDP']) > 0 then
if string.len(frame.args['Bright Gens Up']) > 0 then
udp = p.parse_udp(frame.args['UDP'])
generators_up = tonumber(frame.args['Bright Gens Up'])
end
end
Line 300: Line 294:
-- Get the gamut
-- Get the gamut
local gamut = mosg.mos_gamut(input_mos, generators_up, step_ratio, note_symbols, chroma_plus_symbol, chroma_minus_symbol)
local gamut = mosg.mos_gamut(input_mos, udp, step_ratio, note_symbols, chroma_plus_symbol, chroma_minus_symbol)


-- Get the scale degrees
-- Get the scale degrees