Module:Infobox ET: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 8: | Line 8: | ||
-- towards is one of: -1 (floor), 0 (nearest), 1 (ceil) | -- towards is one of: -1 (floor), 0 (nearest), 1 (ceil) | ||
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 | ||
| Line 16: | Line 16: | ||
local ratio = rat.new(approx, et.size) | local ratio = rat.new(approx, et.size) | ||
local convergement_notice = '' | local convergement_notice = '' | ||
if | if p.debug_mode then | ||
local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave))) | local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave))) | ||
if converges then | if converges then | ||
| Line 39: | Line 39: | ||
-- debug mode | -- debug mode | ||
local debug_mode = frame.args['debug'] ~= nil | local debug_mode = frame.args['debug'] ~= nil | ||
p.debug_mode = debug_mode | |||
local tuning = frame.args['tuning'] | local tuning = frame.args['tuning'] | ||
| Line 103: | Line 104: | ||
}) | }) | ||
if not rat.eq(et.equave, rat.new(3, 2)) then | if not rat.eq(et.equave, rat.new(3, 2)) then | ||
table.insert(infobox_data, { | |||
'Fifth', | |||
approximation(et, 3/2) | |||
}) | |||
end | end | ||
if not rat.eq(et.equave, 2) then | if not rat.eq(et.equave, 2) then | ||
table.insert(infobox_data, { | |||
'Octave', | |||
approximation(et, 2) | |||
}) | |||
end | end | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||