Module:MOS tunings: Difference between revisions

Ganaram inukshuk (talk | contribs)
todo
Ganaram inukshuk (talk | contribs)
Refined ratio-parsing function
Line 224: Line 224:
function p.parse_step_ratios(unparsed)
function p.parse_step_ratios(unparsed)
local parsed = {}
local parsed = {}
if unparsed == "Central Spectrum" then
if unparsed == "" or unparsed == "Simple Tunings" then
parsed = {{2,1}, {3,1}, {3,2}} -- Default is the simple step ratios
elseif unparsed == "NONE" then
parsed = {}
elseif unparsed == "Central Spectrum" then
parsed = {{4,3}, {3,2}, {5,3}, {2,1}, {5,2}, {3,1}, {4,1}}
parsed = {{4,3}, {3,2}, {5,3}, {2,1}, {5,2}, {3,1}, {4,1}}
elseif unparsed == "Soft-of-basic" then
elseif unparsed == "Soft-of-basic" then
Line 234: Line 238:
elseif unparsed == "Hard-of-basic" then
elseif unparsed == "Hard-of-basic" then
parsed = {{2,1}, {3,1}, {4,1}}
parsed = {{2,1}, {3,1}, {4,1}}
elseif unparsed == "" or unparsed == "Simple Tunings" then
-- Default is the simple step ratios
parsed = {{2,1}, {3,1}, {3,2}}
else
else
parsed = tip.parse_numeric_pairs(unparsed)
parsed = tip.parse_numeric_pairs(unparsed)
Line 251: Line 252:
function p.parse_ji_ratios(unparsed, equave_in_cents)
function p.parse_ji_ratios(unparsed, equave_in_cents)
local parsed = nil
local parsed = nil
local parsed_as_search_params = jira.parse_search_params(unparsed)
local parsed_as_ratios = tip.parse_numeric_pairs(unparsed, "/")
if unparsed == "" then
if unparsed == "NONE" then
parsed = jira.search_by_params({["Int Limit"] = 32, ["Tenney Height"] = 9, ["Prime Limit"] = 13}, equave_in_cents)
elseif unparsed == "NONE" then
parsed = {}
parsed = {}
elseif #parsed_as_ratios ~= 0 then
elseif string.match(unparsed, "Int Limit") then
parsed = parsed_as_ratios
local search_params = jira.parse_search_params(unparsed)
elseif unparsed == "" then
parsed = jira.search_by_params(search_params, equave_in_cents)
parsed = nil
else
else
if #parse_as_search_params == 0 then
parsed = jira.parse_ratios(unparsed)
parsed = jira.search_by_params({["Int Limit"] = 32, ["Tenney Height"] = 9, ["Prime Limit"] = 13}, equave_in_cents)
else
parsed = jira.search_by_params(parsed_as_search_params, equave_in_cents)
end
end
end
return parsed
return parsed
end
end
Line 280: Line 278:
local collapsed  = yesno(frame.args["Collapsed"], false) -- Currently does nothing
local collapsed  = yesno(frame.args["Collapsed"], false) -- Currently does nothing
local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"])
local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"])
local ji_ratios  = p.parse_ji_ratios(frame.args["JI Ratios"], equave_in_cents) or jira.search_by_params({["Int Limit"] = 32, ["Tenney Height"] = 9, ["Prime Limit"] = 13}, equave_in_cents)
local ji_ratios  = p.parse_ji_ratios(frame.args["JI Ratios"], equave_in_cents)


-- Verify name/prefix/abbrev
-- Verify name/prefix/abbrev