Module:JI ratios: Difference between revisions
Rename/reorganize functions; add prime-limit search by reusing subgroup-search code |
Int-limit search now removes ratios that exceed the equave |
||
| Line 100: | Line 100: | ||
int_limit = math.max(0, math.min(INT_LIMIT_MAX, int_limit)) | int_limit = math.max(0, math.min(INT_LIMIT_MAX, int_limit)) | ||
local init_ratios = {{1,1}, { | 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 108: | Line 108: | ||
for i = 1, #ratios do | for i = 1, #ratios do | ||
ratios[i] = rat.new(ratios[i][1], ratios[i][2]) | ratios[i] = rat.new(ratios[i][1], ratios[i][2]) | ||
end | |||
-- Remove ratios that exceed the equave. | |||
-- Note that mediant search results in sorted ratios, so remove them from | |||
-- the end until there's no more to remove. | |||
while rat.gt(ratios[#ratios], equave) do | |||
table.remove(ratios, #ratios) | |||
end | end | ||
| Line 270: | Line 277: | ||
if params["Int Limit"] ~= nil then | if params["Int Limit"] ~= nil then | ||
ratios = p.search_by_int_limit(params["Int Limit"], max_cents) | ratios = p.search_by_int_limit(params["Int Limit"], max_cents) | ||
end | end | ||
| Line 316: | Line 319: | ||
---------------------------- RATIO FILTER FUNCTIONS ---------------------------- | ---------------------------- RATIO FILTER FUNCTIONS ---------------------------- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Ratio filter functions are, for the most part, no longer needed. | |||
-- Filter ratios by Tenney height. | -- Filter ratios by Tenney height. | ||
| Line 343: | Line 348: | ||
end | end | ||
return filtered_ratios | return filtered_ratios | ||
end | end | ||
| Line 439: | Line 433: | ||
function p.tester() | function p.tester() | ||
local ratios = p. | local ratios = p.search_by_int_limit_within_equave(30, rat.new(4000,2999)) | ||
return p.ratios_as_text(ratios) | return p.ratios_as_text(ratios) | ||