Module:MOS tuning spectrum: Difference between revisions
adopt simplify_ratio function from mediants module |
code cleanup; adopt sorting function for when custom initial ratios are entered |
||
| Line 19: | Line 19: | ||
default_ratios, default_depths = mediants.find_mediants({{1,1}, {1,0}}, default_depth) | default_ratios, default_depths = mediants.find_mediants({{1,1}, {1,0}}, default_depth) | ||
-- Extract info from args | |||
local input_mos = args["Input MOS" ] or mos.new(5, 2) | local input_mos = args["Input MOS" ] or mos.new(5, 2) | ||
local comments = args["Comments" ] or {} | local comments = args["Comments" ] or {} | ||
local step_ratios = args["Step Ratios"] or default_ratios | local step_ratios = args["Step Ratios"] or default_ratios | ||
local depths = args["Depths" ] or default_depths | local depths = args["Depths" ] or default_depths | ||
-- Find the deepest searched depth at which ratios were found | |||
local deepest = mediants.deepest_depth(depths) | |||
-- Find mos info | |||
local equave = input_mos.equave | local equave = input_mos.equave | ||
local large_steps = input_mos.nL -- Large steps in mos | local large_steps = input_mos.nL -- Large steps in mos | ||
local small_steps = input_mos.ns -- Small steps in mos | local small_steps = input_mos.ns -- Small steps in mos | ||
local periods = mos.period_count(input_mos) -- Number of periods | local periods = mos.period_count(input_mos) -- Number of periods | ||
local et_suffix = mos.et_suffix(input_mos) -- Mos's ET suffix (edo, edt, edf, ed-p/q, etc) | |||
-- Default comments for TAMNAMS-named step ratios | -- Default comments for TAMNAMS-named step ratios | ||
| Line 172: | Line 174: | ||
local initial_ratios = {} | local initial_ratios = {} | ||
if initial_ratios_unparsed ~= nil then | if initial_ratios_unparsed ~= nil then | ||
initial_ratios = tip.parse_numeric_pairs(initial_ratios_unparsed, " | -- Parse initial ratios, then sort by ascending | ||
initial_ratios = tip.parse_numeric_pairs(initial_ratios_unparsed, ";", "/", true) | |||
mediants.sort_ratios(initial_ratios) | |||
else | else | ||
-- If no initial ratios were passed in, default to 1/1 and 1/0 | |||
initial_ratios = {{1,1}, {1,0}} | initial_ratios = {{1,1}, {1,0}} | ||
end | end | ||
| Line 180: | Line 185: | ||
-- If using depth-based search, parse the depth, then remove it from args | -- If using depth-based search, parse the depth, then remove it from args | ||
-- If using int-limit search, parse the int limit, then remove it from args, | -- If using int-limit search, parse the int limit, then remove it from args, | ||
-- and remove depth | -- and remove depth in case it was present. | ||
local step_ratios, depths | local step_ratios, depths | ||
local use_int_limit = args["Int Limit"] ~= nil | local use_int_limit = args["Int Limit"] ~= nil | ||
| Line 197: | Line 202: | ||
step_ratios, depths = mediants.find_mediants(initial_ratios, depth) | step_ratios, depths = mediants.find_mediants(initial_ratios, depth) | ||
end | end | ||
args["Depth"] = nil | args["Depth" ] = nil | ||
args["Step Ratios"] = step_ratios | args["Step Ratios"] = step_ratios | ||
args["Depths"] = depths | args["Depths" ] = depths | ||
-- Transfer comments from args to comments | -- Transfer comments from args to comments | ||