Module:MOS degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
Undo revision 145418 by Ganaram inukshuk (talk) Undo to investigate errors with infobox
Tag: Undo
Ganaram inukshuk (talk | contribs)
Adopt tamnams module for lookup (again)
Line 5: Line 5:
local et = require('Module:ET')
local et = require('Module:ET')
--local jiraf = require('Module:JI ratio finder')
--local jiraf = require('Module:JI ratio finder')
local tamnams = require('Module:TAMNAMS')
local p = {}
local p = {}


Line 11: Line 12:
-- and doesn't depend on genchains (except for note names) to calculate cent values or degree names.
-- and doesn't depend on genchains (except for note names) to calculate cent values or degree names.
-- Current TODO list:
-- Current TODO list:
-- - Rewrite "main function" into a underscore-prefixed function to be called
--  by lua code and a wrapper to be called by templates. (HIGH PRIORITY!!!)
-- - Adopt mos arithmetic function (MEDIUM-PRIORITY!!!)
-- - Add support for double accidentals (low-priority)
-- - Add support for double accidentals (low-priority)
-- - Move certain helper functions to helper modules (low-priority)
-- - Move certain helper functions to helper modules (low-priority)
Line 118: Line 122:
function p.interval_to_etsteps(mosstep_vector, step_ratios)
function p.interval_to_etsteps(mosstep_vector, step_ratios)
return mosstep_vector['L'] * step_ratios[1] + mosstep_vector['s'] * step_ratios[2]
return mosstep_vector['L'] * step_ratios[1] + mosstep_vector['s'] * step_ratios[2]
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 767: Line 752:
mos_prefix = ""
mos_prefix = ""
elseif string.len(frame.args['MOS Prefix']) == 0 then
elseif string.len(frame.args['MOS Prefix']) == 0 then
mos_prefix_lookup = p.get_mos_prefix(scale_sig)
mos_prefix_lookup = tamnams.lookup_prefix(scale_sig)
if string.len(mos_prefix_lookup) ~= 0 then
if string.len(mos_prefix_lookup) ~= 0 then
mos_prefix = mos_prefix_lookup
mos_prefix = mos_prefix_lookup