Module:MOS tunings: Difference between revisions
m Footnote |
Add in tolerance option for displaying ratios |
||
| Line 96: | Line 96: | ||
-- Preprocess step ratios | -- Preprocess step ratios | ||
function p.preprocess_ji_ratios(input_mos, modal_union, step_ratios, ji_ratios) | function p.preprocess_ji_ratios(input_mos, modal_union, step_ratios, ji_ratios, tolerance) | ||
-- Calculate the avegrage step ratio | -- Calculate the avegrage step ratio | ||
| Line 122: | Line 122: | ||
-- 30% of the small step size, and maxes out at 30 cents. | -- 30% of the small step size, and maxes out at 30 cents. | ||
local steps_in_et = input_mos.nL * avg_step_ratio[1] + input_mos.ns * avg_step_ratio[2] | local steps_in_et = input_mos.nL * avg_step_ratio[1] + input_mos.ns * avg_step_ratio[2] | ||
local tolerance = math.min((mos.equave_to_cents(input_mos) / steps_in_et) * 0.30, 30) | local tolerance = tolerance or math.min((mos.equave_to_cents(input_mos) / steps_in_et) * 0.30, 30) | ||
-- Calculate the cent values for each interval in the modal union | -- Calculate the cent values for each interval in the modal union | ||
| Line 136: | Line 136: | ||
-- Main function | -- Main function | ||
function p._mos_tunings(input_mos, mos_prefix, mos_abbrev, step_ratios, ji_ratios, footnotes, is_collapsed) | function p._mos_tunings(input_mos, mos_prefix, mos_abbrev, step_ratios, ji_ratios, tolerance, footnotes, is_collapsed) | ||
local input_mos = input_mos or mos.new(5,2) | local input_mos = input_mos or mos.new(5,2) | ||
local mos_prefix = mos_prefix or "mos" | local mos_prefix = mos_prefix or "mos" | ||
| Line 142: | Line 142: | ||
local step_ratios = step_ratios or {{2, 1}, {3, 1}, {3, 2}} | local step_ratios = step_ratios or {{2, 1}, {3, 1}, {3, 2}} | ||
local ji_ratios = ji_ratios or {} | local ji_ratios = ji_ratios or {} | ||
local tolerance = tolerance or nil | |||
local is_collapsed = is_collapsed == true | local is_collapsed = is_collapsed == true | ||
local footnotes = footnotes or "(footnotes here)" | local footnotes = footnotes or "(footnotes here)" | ||
| Line 300: | Line 301: | ||
function p.mos_tunings(frame) | function p.mos_tunings(frame) | ||
-- Get params | -- Get params | ||
local scalesig | local scalesig = frame.args["Scale Signature"] | ||
local input_mos = mos.parse(scalesig) | local input_mos = mos.parse(scalesig) | ||
local mos_prefix = tamnams.verify_prefix(input_mos, frame.args["MOS Prefix"]) | local mos_prefix = tamnams.verify_prefix(input_mos, frame.args["MOS Prefix"]) | ||
local mos_abbrev = tamnams.verify_abbrev(input_mos, frame.args["MOS Abbrev"]) | local mos_abbrev = tamnams.verify_abbrev(input_mos, frame.args["MOS Abbrev"]) | ||
local is_collapsed = yesno(frame.args["Collapsed"], false) | local is_collapsed = yesno(frame.args["Collapsed"], false) | ||
local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"]) | local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"]) | ||
local tolerance = tonumber(frame.args["Tolerance"]) | |||
local ji_ratios, footnotes = p.parse_ji_ratios(frame.args["JI Ratios"], input_mos.equave) | local ji_ratios, footnotes = p.parse_ji_ratios(frame.args["JI Ratios"], input_mos.equave) | ||
return p._mos_tunings(input_mos, mos_prefix, mos_abbrev, step_ratios, ji_ratios, footnotes, is_collapsed) | return p._mos_tunings(input_mos, mos_prefix, mos_abbrev, step_ratios, ji_ratios, tolerance, footnotes, is_collapsed) | ||
end | end | ||