Module:MOS degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
Trying something with default params
Line 12: Line 12:
function p.mos_degrees_frame(frame)
function p.mos_degrees_frame(frame)
-- Default parameters for input mos and step ratio (5L 2s and 2:1 step ratio)
-- Default parameters for input mos and step ratio (5L 2s and 2:1 step ratio)
local input_mos_unparsed = frame.args['Scale Signature']
local input_mos = mos.parse(frame.args['Scale Signature']) or mos.new(2, 5, 2)
local input_mos = mos.parse(input_mos_unparsed) or mos.new(2, 5, 2)
-- Step ratio
-- Step ratio
local step_ratio = { 2, 1 }
local step_ratio = mosnot.parse_step_ratio(frame.args['Step Ratio']) or { 2, 1 }
if string.len(frame.args['Step Ratio']) > 0 then
step_ratio = mosnot.parse_step_ratio(frame.args['Step Ratio'])
end
-- Get the number of mossteps per period and equave
-- Get the number of mossteps per period and equave
Line 34: Line 30:
-- two instead.
-- two instead.
-- If it's 5L 2s, default to the second-brightest mode.
-- If it's 5L 2s, default to the second-brightest mode.
local udp = { periods_per_equave * math.ceil((mossteps_per_period - 1)/ 2), periods_per_equave * math.floor((mossteps_per_period - 1) / 2) }
local udp_default = { periods_per_equave * math.ceil((mossteps_per_period - 1)/ 2), periods_per_equave * math.floor((mossteps_per_period - 1) / 2) }
if scale_sig == "5L 2s" then
if scale_sig == "5L 2s" then
udp = { 5, 1 }
udp_default = { 5, 1 }
end
if string.len(frame.args['UDP']) > 0 then
udp = mosnot.parse_udp(frame.args['UDP'])
end
end
local udp = mosnot.parse_udp(frame.args['UDP']) or udp_default
local generators_up = udp[1]
local generators_up = udp[1]
local generators_down = udp[2]
local generators_down = udp[2]
Line 50: Line 44:
-- This order of operations allows for overriding standard notation for 5L 2s
-- This order of operations allows for overriding standard notation for 5L 2s
local note_symbols_main = "JKLMNOPQRSTUVWXYZ"
local note_symbols_main = "JKLMNOPQRSTUVWXYZ"
local note_symbols = string.sub(note_symbols_main, 1, mossteps_per_equave)
local note_symbols_default = string.sub(note_symbols_main, 1, mossteps_per_equave)
if scale_sig == "5L 2s" then
if scale_sig == "5L 2s" then
note_symbols = "CDEFGAB"
note_symbols_default = "CDEFGAB"
end
-- If a value was entered, override the default value
if string.len(frame.args['Note Symbols']) > 0 then
note_symbols = frame.args['Note Symbols']
end
end
local note_symbols = frame.args['Note Symbols'] or note_symbols_default
-- Get accidental symbols
-- Get accidental symbols
Line 63: Line 54:
-- unless the mos is 5L 2s, then it's sharp and flat # and b
-- unless the mos is 5L 2s, then it's sharp and flat # and b
-- This order of operations allows for overriding standard notation for 5L 2s
-- This order of operations allows for overriding standard notation for 5L 2s
local chroma_plus_symbol = "&"
local sharp_default = "&"
local chroma_minus_symbol = "@"
local flat_default = "@"
if scale_sig == "5L 2s" then
if scale_sig == "5L 2s" then
chroma_plus_symbol = "#"
sharp_default = "#"
chroma_minus_symbol = "b"
flat_default = "b"
end
-- If value(s) were entered, override the default values
if string.len(frame.args['Sharp Symbol']) > 0 then
chroma_plus_symbol = frame.args['Sharp Symbol']
end
if string.len(frame.args['Flat Symbol']) > 0 then
chroma_minus_symbol = frame.args['Flat Symbol']
end
end
local chroma_plus_symbol = frame.args['Sharp Symbol'] or sharp_default
local chroma_minus_symbol = frame.args['Flat Symbol'] or flat_default
-- Override values for testing
-- Override values for testing