Module:JI ratio finder: Difference between revisions
Added filtering by equave-complement int-limit |
Removed functions pertaining to complement-agnostic tenney height; superseded by nefth functions |
||
Line 3: | Line 3: | ||
local rat = require('Module:Rational') | local rat = require('Module:Rational') | ||
local p = {} | local p = {} | ||
-- Finds the Tenney height of a ratio that ignores equave factors. | -- Finds the Tenney height of a ratio that ignores equave factors. | ||
-- If the equave is 2/1, then this is equivalent to no-2's Tenney Height. | -- If the equave is 2/1, then this is equivalent to no-2's Tenney Height. | ||
-- This is an attempt at generalizing no-2's Tenney height for nonoctave | -- This is an attempt at generalizing no-2's Tenney height for nonoctave | ||
-- equaves, such as 3/1 or 3/2. | -- equaves, such as 3/1 or 3/2, which would be no-2's and no-2's-or-3's. | ||
function p.no_equave_factors_tenney_height(ratio, equave) | function p.no_equave_factors_tenney_height(ratio, equave) | ||
local ratio = ratio or rat.new(81, 64) | local ratio = ratio or rat.new(81, 64) | ||
Line 63: | Line 51: | ||
-- Ratios found this way will range from 0 cents to the given cent value. | -- Ratios found this way will range from 0 cents to the given cent value. | ||
-- These ratios should then be filtered as needed. | -- These ratios should then be filtered as needed. | ||
function p. | function p.find_candidate_ratios_within_prime_limit(cents, int_limit, prime_limit) | ||
local cents = cents or | local cents = cents or 1200 | ||
local int_limit = int_limit or 99 | local int_limit = int_limit or 99 | ||
local prime_limit = prime_limit or 97 | local prime_limit = prime_limit or 97 | ||
Line 213: | Line 201: | ||
function p.filter_ratios_by_subgroup(ratios, subgroup) | function p.filter_ratios_by_subgroup(ratios, subgroup) | ||
local ratios = ratios or { rat.new(1), rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) } | local ratios = ratios or { rat.new(1), rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) } | ||
local subgroup = subgroup or { 2, 3, | local subgroup = subgroup or { 2, 3, 7 } | ||
local candidate_ratios = p.filter_ratios_by_prime_limit(ratios, subgroup[#subgroup]) | local candidate_ratios = p.filter_ratios_by_prime_limit(ratios, subgroup[#subgroup]) | ||
Line 238: | Line 226: | ||
for i = 1, #ratios do | for i = 1, #ratios do | ||
if rat.tenney_height(ratios[i]) <= tenney_height then | if rat.tenney_height(ratios[i]) <= tenney_height then | ||
table.insert(filtered_ratios, ratios[i]) | table.insert(filtered_ratios, ratios[i]) | ||
end | end | ||
Line 267: | Line 235: | ||
-- Filters ratios by no-equave-factors Tenney height | -- Filters ratios by no-equave-factors Tenney height | ||
-- Filters ratios where lg(numerator) + lg(denominator) does not exceed the | -- Filters ratios where lg(numerator) + lg(denominator) does not exceed the | ||
-- given height, where lg is log-base-2 | -- given height, where lg is log-base-2. If the equave is 2/1, this is the same | ||
-- as no-2's tenney height. | |||
-- | -- EG, assuming 2/1 equave, 3/2 and 4/3 have the same tenney height of lg(3). | ||
function p.filter_ratios_by_no_equave_factors_tenney_height(ratios, tenney_height, equave) | function p.filter_ratios_by_no_equave_factors_tenney_height(ratios, tenney_height, equave) | ||
local ratios = ratios or { rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) } | local ratios = ratios or { rat.new(5, 4), rat.new(81, 64), rat.new(9, 7) } |