Module:JI ratios: Difference between revisions
m betterer wording for footnote |
Added complement-only search (does not work for int-limit-only search): ratios are only added based on whether its equave complement is also added |
||
| Line 46: | Line 46: | ||
end | end | ||
function p. | function p.ratio_within_search(ratio, equave, fine_search_args) | ||
local | local complement = rat.mul(rat.new(ratio[2], ratio[1]), equave) | ||
local a, b = rat.as_pair(complement) | local a, b = rat.as_pair(complement) | ||
-- Ratio, complement, and equave as float | |||
local ratio_as_float = ratio[1] / ratio[2] | |||
local equave_as_float = rat.as_float(equave) | |||
-- Fine search params for ease of access | |||
local int_limit = fine_search_args["Int Limit"] | |||
local tenney_height = fine_search_args["Tenney Height"] | |||
local comps_only = fine_search_args["Complements Only"] | |||
local ratio_within_int_limit = math.max(ratio[1], ratio[2]) <= int_limit | |||
local ratio_within_tenney_height = math.log(ratio[1] * ratio[2]) / math.log(2) <= tenney_height | |||
local ratio_within_equave = ratio_as_float <= equave_as_float | |||
local ratio_within_search = ratio_within_int_limit and ratio_within_tenney_height and ratio_within_equave | |||
local comp_within_search = true | |||
if comps_only then | |||
-- A ratio's complement will be necessarily less than or equal to the | |||
-- equave, so no need to check if it's within the equave. | |||
local comp_within_int_limit = math.max(a, b) <= int_limit | |||
local comp_within_tenney_height = math.log(a * b) / math.log(2) <= tenney_height | |||
comp_within_search = comp_within_int_limit and comp_within_tenney_height | |||
end | |||
return ratio_within_search and comp_within_search | |||
end | end | ||
| Line 99: | Line 121: | ||
local ratio_1 = mediant_data["ratio_1"] | local ratio_1 = mediant_data["ratio_1"] | ||
local equave = search_args["Equave"] | local equave = search_args["Equave"] | ||
local equave_as_float = rat.as_float(equave) | local equave_as_float = rat.as_float(equave) | ||
| Line 107: | Line 126: | ||
local mediant_th = math.log(mediant[1] * mediant[2]) / math.log(2) | local mediant_th = math.log(mediant[1] * mediant[2]) / math.log(2) | ||
-- When the ratio is added, is ratio 1 within the equave? If so, add the | |||
-- new ratio. | |||
local within_equave = rat_1_as_float < equave_as_float | local within_equave = rat_1_as_float < equave_as_float | ||
return within_int_limit | -- Is the mediant within the int limit and tenney height? | ||
local within_int_limit = math.max(mediant[1], mediant[2]) <= search_args["Int Limit"] | |||
local within_tenney_height = mediant_th <= search_args["Tenney Height"] | |||
return within_equave and within_int_limit and within_tenney_height | |||
end | end | ||
| Line 190: | Line 212: | ||
if gcd == 1 then | if gcd == 1 then | ||
local ratio = {numerator, denominator} | local ratio = {numerator, denominator} | ||
if | if p.ratio_within_search(ratio, equave, fine_search_args) then | ||
table.insert(ratios, ratio) | table.insert(ratios, ratio) | ||
else | else | ||
| Line 403: | Line 422: | ||
local equave = rat.new(2,1) | local equave = rat.new(2,1) | ||
local fine_search_args = { | local fine_search_args = { | ||
["Int Limit"] = | ["Int Limit"] = 27, | ||
["Tenney Height"] = 1/0, | ["Tenney Height"] = 1/0, | ||
["Complements Only"] = | ["Complements Only"] = true | ||
} | } | ||
return p.ratios_as_text(p. | return p.ratios_as_text(p.search_by_prime_limit_within_equave(7, equave, fine_search_args)) | ||
--return p.ratio_within_search({9,8}, equave, fine_search_args) | |||
end | end | ||
return p | return p | ||