Module:JI ratios: Difference between revisions
m Rename functions |
Add subgroup and prime limit options to search-by-params |
||
| Line 49: | Line 49: | ||
local tenney_height = tenney_height or 1/0 -- Defualt tenney height is infinity. | local tenney_height = tenney_height or 1/0 -- Defualt tenney height is infinity. | ||
int_limit = math.max( | int_limit = math.max(1, math.min(INT_LIMIT_MAX, int_limit)) | ||
local init_ratios = {{1,1}, {1,0} } | local init_ratios = {{1,1}, {1,0}} | ||
local search_func = p.int_limit_mediant_search | local search_func = p.int_limit_mediant_search | ||
local search_args = { ["equave"] = equave, ["int_limit"] = int_limit, ["tenney_height"] = tenney_height } | local search_args = { ["equave"] = equave, ["int_limit"] = int_limit, ["tenney_height"] = tenney_height } | ||
| Line 182: | Line 182: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | -- Prime-limit-based search; finds ratios between 1/1 and an equave, within a | ||
-- prime limit. An int limit is passed in to limit the size of output, since | -- prime limit. An int limit is passed in to limit the size of output, since | ||
-- prime limits are inifinite sets. An optional tenney height can be passed in | -- prime limits are inifinite sets. An optional tenney height can be passed in | ||
| Line 218: | Line 218: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Search for ratios based on params passed in. | -- Search for ratios based on params passed in. Certain params have their own | ||
-- function | -- function calls. | ||
function p.search_by_params(params, equave) | function p.search_by_params(params, equave) | ||
local equave = equave or rat.new(2,1) | local equave = equave or rat.new(2,1) | ||
| Line 226: | Line 226: | ||
-- will default to the hardcoded default value. | -- will default to the hardcoded default value. | ||
local ratios = {} | local ratios = {} | ||
if params["Int Limit"] ~= nil then | if params["Prime Limit"] ~= nil and params["Int Limit"] ~= nil then | ||
ratios = p.search_by_prime_limit_within_equave(params["Prime Limit"], equave, params["Int Limit"], params["Tenney Height"]) | |||
elseif params["Subgroup"] ~= nil and params["Int Limit"] ~= nil then | |||
ratios = p.search_by_subgroup_within_equave(params["Subgroup"], equave, params["Int Limit"], params["Tenney Height"]) | |||
elseif params["Int Limit"] ~= nil then | |||
ratios = p.search_within_equave(equave, params["Int Limit"], params["Tenney Height"]) | ratios = p.search_within_equave(equave, params["Int Limit"], params["Tenney Height"]) | ||
end | end | ||
| Line 242: | Line 246: | ||
if parsed["Tenney Height"] ~= nil then | if parsed["Tenney Height"] ~= nil then | ||
parsed["Tenney Height"] = tonumber(parsed["Tenney Height"]) | parsed["Tenney Height"] = tonumber(parsed["Tenney Height"]) | ||
end | |||
if parsed["Prime Limit"] ~= nil then | |||
parsed["Prime Limit"] = tonumber(parsed["Prime Limit"]) | |||
end | |||
if parsed["Subgroup"] ~= nil then | |||
parsed["Subgroup"] = tip.parse_numeric_entries(parsed["Subgroup"], ".") | |||
end | end | ||
| Line 249: | Line 261: | ||
function p.search_param_footnotes(search_params) | function p.search_param_footnotes(search_params) | ||
local result = "Not all notable ratios may be shown, and other interpretations are possible." | local result = "Not all notable ratios may be shown, and other interpretations are possible." | ||
local search_text = "" | |||
if search_params[" | if search_params["Prime Limit"] ~= nil then | ||
search_text = string.format("Ratios shown are within the %s-prime limit.", search_params["Prime Limit"]) | |||
elseif search_params["Subgroup"] ~= nil then | |||
search_text = string.format("Ratios shown are within the %s subgroup.", table.concat(search_params["Subgroup"], ".")) | |||
elseif search_params["Int Limit"] ~= nil then | |||
search_text = string.format("Ratios shown are within the %s-integer limit.", search_params["Int Limit"]) | |||
end | end | ||
result = search_text .. " " .. result | |||
return result | return result | ||
end | end | ||
| Line 341: | Line 358: | ||
function p.tester() | function p.tester() | ||
return p.ratios_as_text(ratios) | --return p.ratios_as_text(ratios) | ||
return p.parse_search_params("Prime Limit: 19") | |||
end | end | ||
return p | return p | ||