Module:Interval edo approximation: Difference between revisions
m bug fixing |
m bug fixing |
||
| Line 1: | Line 1: | ||
-- EDO Approximations Module | -- EDO Approximations Module | ||
-- Calculates EDO approximations for just intervals | -- Calculates EDO approximations for just intervals | ||
-- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo= | -- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=5|max_edo=60}} | ||
local p = {} | local p = {} | ||
-- ===== CONFIGURATION VARIABLES ===== | |||
local DEFAULT_TOLERANCE = 9.0 -- Relative error tolerance in percent | |||
local DEFAULT_MIN_EDO = 5 -- Minimum EDO to check | |||
local DEFAULT_MAX_EDO = 60 -- Maximum EDO to check | |||
-- ==================================== | |||
-- Convert a frequency ratio to cents | -- Convert a frequency ratio to cents | ||
| Line 112: | Line 118: | ||
local interval_str = args.interval or args[1] | local interval_str = args.interval or args[1] | ||
-- Convert string parameters to numbers | -- Convert string parameters to numbers using config defaults | ||
local tolerance = tonumber(args.tolerance) or DEFAULT_TOLERANCE | |||
local tolerance = tonumber(args.tolerance) or | local min_edo = tonumber(args.min_edo) or DEFAULT_MIN_EDO | ||
local min_edo = tonumber(args.min_edo) or | local max_edo = tonumber(args.max_edo) or DEFAULT_MAX_EDO | ||
local max_edo = tonumber(args.max_edo) or | |||
-- Validate interval parameter | -- Validate interval parameter (required, no default) | ||
if not interval_str then | if not interval_str then | ||
return "Error: No interval specified" | return "Error: No interval specified" | ||