Module:Interval edo approximation: Difference between revisions
No edit summary |
Don't invent the wheel |
||
| Line 2: | Line 2: | ||
-- Calculates EDO approximations for just intervals | -- Calculates EDO approximations for just intervals | ||
-- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=5|max_edo=60}} | -- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=5|max_edo=60}} | ||
local u = require("Module:Utils") | |||
local yesno = require("Module:Yesno") | local yesno = require("Module:Yesno") | ||
local p = {} | local p = {} | ||
| Line 14: | Line 15: | ||
-- Python: return 1200 * math.log2(ratio) | -- Python: return 1200 * math.log2(ratio) | ||
local function cents(ratio) | local function cents(ratio) | ||
return 1200 * u.log2(ratio) | |||
return 1200 * | |||
end | end | ||
| Line 129: | Line 103: | ||
-- Parse interval string to numeric ratio | -- Parse interval string to numeric ratio | ||
local ratio = | local ratio = eval_num_arg(interval_str) | ||
if not ratio then | if not ratio then | ||
return "Error: Invalid interval format (use format like '3/2')" | return "Error: Invalid interval format (use format like '3/2')" | ||