Module:Infobox ET: Difference between revisions
mNo edit summary |
Stabilising convergement notices |
||
| Line 10: | Line 10: | ||
local function approximation(et, interval, towards, precomputed_approx) | local function approximation(et, interval, towards, precomputed_approx) | ||
local approx = precomputed_approx or ET.approximate(et, interval, towards or 0) | local approx = precomputed_approx or ET.approximate(et, interval, towards or 0) | ||
local tuning = et.size | local tuning = et.size | ||
if not rat.eq(et.equave, 2) then | if not rat.eq(et.equave, 2) then | ||
tuning = tuning .. et.suffix | tuning = tuning .. et.suffix | ||
end | end | ||
local ratio = rat.new(approx, et.size) | local ratio = rat.new(approx, et.size) | ||
local convergement_notice = '' | local convergement_notice = '' | ||
local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave))) | |||
if converges then | |||
convergement_notice = '<br/>(' .. converges .. ')' | |||
end | end | ||
if rat.as_table(ratio)[1] ~= approx then | if rat.as_table(ratio)[1] ~= approx then | ||
local link = rat.as_table(ratio)[2] .. et.suffix | local link = rat.as_table(ratio)[2] .. et.suffix | ||
| Line 32: | Line 34: | ||
ratio = '' | ratio = '' | ||
end | end | ||
local cents = u._round(ET.cents(et, approx), 6) | local cents = u._round(ET.cents(et, approx), 6) | ||
return approx .. '\\' .. tuning .. ' (' .. cents .. '¢)' .. ratio .. convergement_notice | return approx .. '\\' .. tuning .. ' (' .. cents .. '¢)' .. ratio .. convergement_notice | ||
end | end | ||
| Line 39: | Line 43: | ||
-- debug mode | -- debug mode | ||
local debug_mode = frame.args['debug'] ~= nil | local debug_mode = frame.args['debug'] ~= nil | ||
local tuning = frame.args['tuning'] | local tuning = frame.args['tuning'] | ||