Module:JI ratio finder: Difference between revisions

Ganaram inukshuk (talk | contribs)
Removed functions pertaining to complement-agnostic tenney height; superseded by nefth functions
ArrowHead294 (talk | contribs)
m Alphabetise dependencies
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
local p = {}
-- local interval = require('Module:Interval')
local rat = require('Module:Rational')
local utils = require('Module:Utils')
local utils = require('Module:Utils')
local interval = require('Module:Interval')
local rat = require('Module:Rational')
local p = {}


-- Finds the Tenney height of a ratio that ignores equave factors.
-- Finds the Tenney height of a ratio that ignores equave factors.
Line 311: Line 312:
-- Converts ratios to text, with delimiter
-- Converts ratios to text, with delimiter
-- Default delimiter is a comma followed by a space
-- Default delimiter is a comma followed by a space
function p.ratios_to_text(ratios, delimiter)
function p.ratios_to_text(ratios, delimiter, add_links)
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) }
local delimiter = delimiter or ", "
local delimiter = delimiter or ", "
local add_links = add_links == true


local text = ""
local text = ""
for i = 1, #ratios do
if add_links then
text = text .. rat.as_ratio(ratios[i])
for i = 1, #ratios do
if i < #ratios then
text = text .. string.format("[[%s]]", rat.as_ratio(ratios[i]))
text = text .. delimiter
if i < #ratios then
text = text .. delimiter
end
end
else
for i = 1, #ratios do
text = text .. rat.as_ratio(ratios[i])
if i < #ratios then
text = text .. delimiter
end
end
end
end
end