Module:MOS intervals: Difference between revisions

Ganaram inukshuk (talk | contribs)
m "L's and s's" -> "Intervals" -> "Steps"
Ganaram inukshuk (talk | contribs)
Adopt tamnams module for lookup
Line 4: Line 4:
local utils = require('Module:Utils')
local utils = require('Module:Utils')
local et = require('Module:ET')
local et = require('Module:ET')
local tamnams = require('Module:TAMNAMS')
local p = {}
local p = {}
-- TODO:
-- - Adopt mos arithmetic functions provided by mos module


-- Helper function that turns a mosstep into a step count as a string
-- Helper function that turns a mosstep into a step count as a string
Line 86: Line 90:
end
end
return result
return result
end
-- Helper function
-- Extracts the prefix from the mos module, without the dash and without any text after that
-- May need to revisit to clean up code since this splits text at the "-"
function p.get_mos_prefix(scale_sig)
local unparsed = mos.tamnams_prefix[scale_sig]
local parsed = {}
if unparsed == nil then
return "mos"
else
for entry in string.gmatch(unparsed, '([^-]+)') do
local trimmed = entry:gsub("^%s*(.-)%s*$", "%1")
table.insert(parsed, trimmed) -- Add to array
end
return parsed[1]
end
end
end


Line 247: Line 232:
-- If not left blank, use the prefix passed in instead
-- If not left blank, use the prefix passed in instead
local scale_sig = mos.as_string(input_mos)
local scale_sig = mos.as_string(input_mos)
local mos_prefix = p.get_mos_prefix(scale_sig)
local mos_prefix = tamnams.lookup_prefix(input_mos)
if frame.args['MOS Prefix'] == "NONE" then
if frame.args['MOS Prefix'] == "NONE" then
mos_prefix = ""
mos_prefix = ""