Module:JI ratios: Difference between revisions
bring back function that parses search args entered as one string |
m comment out some default args, as _ji_ratios() is the main function to be called |
||
| Line 81: | Line 81: | ||
-- numerator or denominator don't exceed the int limit. | -- numerator or denominator don't exceed the int limit. | ||
function p.search_by_int_limit(equave, int_limit) | function p.search_by_int_limit(equave, int_limit) | ||
local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | --local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | ||
local int_limit = int_limit or 50 -- Default is 50 | --local int_limit = int_limit or 50 -- Default is 50 | ||
-- Find all ratios from 1/1 to the equave by finding mediants between 1/1 | -- Find all ratios from 1/1 to the equave by finding mediants between 1/1 | ||
| Line 121: | Line 121: | ||
-- Upper bounds for searching is the equave and int limit. | -- Upper bounds for searching is the equave and int limit. | ||
function p.search_by_prime_limit(equave, int_limit, prime_limit) | function p.search_by_prime_limit(equave, int_limit, prime_limit) | ||
local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | --local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | ||
local int_limit = int_limit or 50 -- Default is 50 | --local int_limit = int_limit or 50 -- Default is 50 | ||
local prime_limit = prime_limit or 5 -- Default is 5-prime-limit | --local prime_limit = prime_limit or 5 -- Default is 5-prime-limit | ||
-- Convert prime limit into an equivalent subgroup (EG, 7-limit becomes | -- Convert prime limit into an equivalent subgroup (EG, 7-limit becomes | ||
| Line 154: | Line 154: | ||
-- Upper bounds for searching is the equave and int limit. | -- Upper bounds for searching is the equave and int limit. | ||
function p.search_by_subgroup(equave, int_limit, subgroup) | function p.search_by_subgroup(equave, int_limit, subgroup) | ||
local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | --local equave = equave or rat.new(2,1) -- Defualt equave is 2/1. | ||
local int_limit = int_limit or 50 -- Default is 50 | --local int_limit = int_limit or 50 -- Default is 50 | ||
local subgroup = subgroup or {rat.new(2), rat.new(3), rat.new(7)} -- Default is 2.3.7 subgroup | --local subgroup = subgroup or {rat.new(2), rat.new(3), rat.new(7)} -- Default is 2.3.7 subgroup | ||
-- Find all possible ways to multiply subgroup elements with one another | -- Find all possible ways to multiply subgroup elements with one another | ||
| Line 271: | Line 271: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Parse search args if entered as one string | -- Parse search args if entered as one string. Use is to be determined. | ||
function p.parse_args(search_args) | function p.parse_args(search_args) | ||
local parsed = tip.parse_kv_pairs(search_args) | local parsed = tip.parse_kv_pairs(search_args) | ||
| Line 311: | Line 311: | ||
-- Function callable by other modules | -- Function callable by other modules | ||
-- Ratios are returned as a table, for use with other modules | -- Ratios are returned as a table, for use with other modules. | ||
function p._ji_ratios(args) | function p._ji_ratios(args) | ||
-- Args for ease of access | -- Args for ease of access | ||
equave = args["Equave"] | equave = args["Equave"] or rat.new(2) | ||
int_limit = args["Int Limit"] | int_limit = args["Int Limit"] or 50 | ||
odd_limit = args["Odd Limit"] | odd_limit = args["Odd Limit"] | ||
prime_limit = args["Prime Limit"] | prime_limit = args["Prime Limit"] | ||
| Line 333: | Line 333: | ||
-- Invokable function; for templates | -- Invokable function; for templates | ||
-- Ratios are returned as a comma-delimited list | -- Ratios are returned as a comma-delimited list, for use with being displayed | ||
-- as a list. | |||
function p.ji_ratios(frame) | function p.ji_ratios(frame) | ||
args = getArgs(frame) | args = getArgs(frame) | ||
| Line 340: | Line 341: | ||
-- Ratios are searched from 1/1 to some equave (default 2/1), so an equave | -- Ratios are searched from 1/1 to some equave (default 2/1), so an equave | ||
-- must be passed in. | -- must be passed in. | ||
args["Equave"] = args["Equave"] ~= nil and rat.parse(args["Equave"] | args["Equave"] = args["Equave"] ~= nil and rat.parse(args["Equave"]) | ||
-- Preprocess int limit | -- Preprocess int limit | ||
-- Ratios are searched up to some int limit (default 50), so an int limit | -- Ratios are searched up to some int limit (default 50), so an int limit | ||
-- must be passed in. | -- must be passed in. | ||
args["Int Limit"] = args["Int Limit"] ~= nil and tonumber(args["Int Limit"]) | args["Int Limit"] = args["Int Limit"] ~= nil and tonumber(args["Int Limit"]) | ||
-- Preprocess Tenney height | -- Preprocess Tenney height | ||