Module:MOS degrees: Difference between revisions
Adopt tamnams module for prefix lookup, adopt some of mos module's new functions |
Undo revision 145418 by Ganaram inukshuk (talk) Undo to investigate errors with infobox Tag: Undo |
||
| 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 jiraf = require('Module:JI ratio finder') | --local jiraf = require('Module:JI ratio finder') | ||
local p = {} | local p = {} | ||
| Line 12: | Line 11: | ||
-- 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: | ||
-- - 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 122: | Line 118: | ||
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 523: | Line 538: | ||
-- 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 | local darkest_mode = string.reverse(brightest_mode) | ||
-- 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 752: | Line 767: | ||
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 = | mos_prefix_lookup = p.get_mos_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 | ||