Module:Rational: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
mNo edit summary
Line 739: Line 739:
end
end
end
end
table.sort(otonal)
table.sort(utonal)
local fifths = b[3] or 0
local fifths = b[3] or 0
-- does not work well when `fifths` is 12+7*n or -12-7*n, n>=0
-- b = p.div(b, red(p.pow(3, fifths)))
-- local octaves = b[2] or 0
b = p.div(b, red(p.pow(3, fifths)))
-- a terrible hack, I have no idea how/why this is supposed to work
local octaves = b[2] or 0
local octaves = (b[2] or 0) + fifths + 4 * math.floor(fifths / 7) + math.floor((fifths % 7) / 2)
local noshift = {1, 5, 2, 6, 3, 7, 4}
local noshift = {1, 5, 2, 6, 3, 7, 4}
Line 749: Line 755:
if octaves < 0 then
if octaves < 0 then
fifths = -fifths
fifths = -fifths
-- wrong results on 3^53/2^84, which should be AAAAAAA3 but is computed as ddddddd-6
octaves = -(b[2] or 0) + fifths + 4 * math.floor(fifths / 7) + math.floor((fifths % 7) / 2)
num = -noshift[1 + (fifths % 7)] - octaves * 7
end
end