Module:Infobox ET: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
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, convergement)
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 convergement then
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
if debug_mode then
table.insert(infobox_data, {
table.insert(infobox_data, {
'Fifth',
'Fifth',
approximation(et, 3/2)
approximation(et, 3/2, nil, nil, true)
})
})
else
table.insert(infobox_data, {
'Fifth',
approximation(et, 3/2)
})
end
end
end
if not rat.eq(et.equave, 2) then
if not rat.eq(et.equave, 2) then
if debug_mode then
table.insert(infobox_data, {
table.insert(infobox_data, {
'Octave',
'Octave',
approximation(et, 2)
approximation(et, 2, nil, nil, true)
})
})
else
table.insert(infobox_data, {
'Octave',
approximation(et, 2)
})
end
end
end
table.insert(infobox_data, {
table.insert(infobox_data, {