Module:MOS degrees: Difference between revisions

ArrowHead294 (talk | contribs)
Move Module:MOS degrees v2 back over here
Ganaram inukshuk (talk | contribs)
Adopt tamnams module for prefix lookup, adopt some of mos module's new functions
Line 4: Line 4:
local mosnot = require('Module:MOS notation')
local mosnot = require('Module:MOS notation')
local et = require('Module:ET')
local et = require('Module:ET')
local tamnams = require('Module:TAMNAMS')
--local jiraf = require('Module:JI ratio finder')
--local jiraf = require('Module:JI ratio finder')
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:
-- - Change main function to two functions: main function that can be called by
--  other modules and wrapper function that can be called by a template (HIGH PRIORITY!!!!)
-- - Adopt mos module's mossteps-to-vector functions (HIGH 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 538: Line 523:
-- Get the brightest and darkest modes for the mos
-- Get the brightest and darkest modes for the mos
local brightest_mode = mos.brightest_mode(input_mos)
local brightest_mode = mos.brightest_mode(input_mos)
local darkest_mode = string.reverse(brightest_mode)
local darkest_mode   = mos.darkest_mode(input_mos)
-- Get the number of mossteps per period and equave, and periods per equave
-- Get the number of mossteps per period and equave, and periods per equave
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