Module:MOS tuning spectrum: Difference between revisions

Ganaram inukshuk (talk | contribs)
Experimenting with option to go by int limit of step ratios
Ganaram inukshuk (talk | contribs)
mNo edit summary
Line 15: Line 15:
local input_mos  = args["Input MOS"] or mos.new(5, 2)
local input_mos  = args["Input MOS"] or mos.new(5, 2)
local depth      = args["Depth"]
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
Line 149: Line 150:
-- Parse depth
-- Parse depth
local depth = tonumber(args["Depth"])
local depth = tonumber(args["Depth"])
args["Depth"] = nil
args["Depth"] = depth
-- If int limit is present, use that over depth
-- If int limit is present, use that over searching for ratios by depth
local int_limit = tonumber(args["Int Limit"])
local int_limit = tonumber(args["Int Limit"])
args["Int Limit"] = int_limit
args["Int Limit"] = int_limit
Line 164: Line 165:
if use_int_limit then
if use_int_limit then
step_ratios, depths = mediants.find_mediants_by_int_limit({first_ratio, last_ratio}, int_limit)
step_ratios, depths = mediants.find_mediants_by_int_limit({first_ratio, last_ratio}, int_limit)
local largest = nil
for _, value in ipairs(depths) do
if not largest or value > largest then
largest = value
end
end
args["Depth"] = largest
else  
else  
step_ratios, depths = mediants.find_mediants({first_ratio, last_ratio}, depth)
step_ratios, depths = mediants.find_mediants({first_ratio, last_ratio}, depth)