Module:Chord consistency: Difference between revisions

Dummy index (talk | contribs)
equave-free veresion of additively_consistent()
Dummy index (talk | contribs)
mark by consistency distance
Line 83: Line 83:
end
end
return true
return true
end
-- determine maximum error
function p.max_error(et, ratios)
local maxe = 0.0
for a_key, a in pairs(ratios) do
local a_approx = ET.approximate(et, rat.as_float(a))
local e = math.abs((ET.cents(et, a_approx) - rat.cents(a)) / ET.cents(et, 1))
if (e > maxe) then
maxe = e
end
end
return maxe
end
end


Line 150: Line 163:
local consistent = p.additively_consistent_int(et, all_interval, false, previous)
local consistent = p.additively_consistent_int(et, all_interval, false, previous)
if consistent then
if consistent then
table.insert(vals, "[[" .. i .. "edo]]")
local maxe = p.max_error(et, all_interval)
local dist = math.ceil(0.5/maxe)-1.0
local llevel = 0
while (dist >= 2) do
llevel = llevel + 1
dist = dist / 2
end
table.insert(vals, "[[" .. i .. "edo]]" .. string.rep("*", llevel))
end
end
end
end