Module:JI ratios in ED: Difference between revisions
Created page with "local utils = require('Module:Utils') local interval = require('Module:Interval') local rat = require('Module:Rational') local jiraf = require('Module:JI ratio finder') local..." |
Separated parse function into two functions (one for the ed, one for the equave) |
||
| Line 55: | Line 55: | ||
function p.parse_ed(unparsed) | function p.parse_ed(unparsed) | ||
local unparsed = unparsed or " | local unparsed = unparsed or "12ed2/1" | ||
local ed = unparsed:match('(%d+)ed') | local ed = tonumber(unparsed) or unparsed:match('(%d+)ed') | ||
return ed | |||
end | |||
function p.parse_equave(unparsed) | |||
local unparsed = unparsed or "12" | |||
local equave_unparsed = "" | local equave_unparsed = "" | ||
if string.match(unparsed, "edo") then | if string.match(unparsed, "edo") or tonumber(unparsed) ~= nil then | ||
equave_unparsed = "2/1" | equave_unparsed = "2/1" | ||
elseif string.match(unparsed, "edt") then | elseif string.match(unparsed, "edt") then | ||
| Line 69: | Line 75: | ||
equave_unparsed = unparsed:match('[%d]+ed([%d]+/[%d]+)') | equave_unparsed = unparsed:match('[%d]+ed([%d]+/[%d]+)') | ||
end | end | ||
return | return rat.parse(equave_unparsed) | ||
end | end | ||
function p.ji_ratios_in_ed_frame(frame) | function p.ji_ratios_in_ed_frame(frame) | ||
local ed | local ed = tonumber(p.parse_ed(frame.args["EDO"])) or p.parse_ed(frame.args["EDO"]) | ||
local | local equave = p.parse_equave(frame.args["EDO"]) or p.parse_ed(frame.args["EDO"]) | ||
local primes = tip.parse_entries(frame.args["Primes"], ",") or { 3, 5, 7, 11, 13, 17, 19 } | local primes = tip.parse_entries(frame.args["Primes"], ",") or { 3, 5, 7, 11, 13, 17, 19 } | ||