Module:Infobox chord: Difference between revisions

Bcmills (talk | contribs)
No edit summary
Bcmills (talk | contribs)
No edit summary
Line 40: Line 40:
local harmonics = {}
local harmonics = {}
for hs in string.gmatch(frame.args["Harmonics"], "[^:]+") do
for hs in string.gmatch(frame.args["Harmonics"], "[^:]+") do
debug_data = debug_data .. "hs:" .. hs .. "<br/>"
h = tonumber(hs)  -- TODO: support rational entries?
h = tonumber(hs)  -- TODO: support rational entries?
if h == nil or h < 1 then
if h == nil or h < 1 then
Line 60: Line 59:


for i, h in ipairs(harmonics) do
for i, h in ipairs(harmonics) do
debug_data = debug_data .. "harmonic" .. h .. "<br/>"
debug_data = debug_data .. "harmonic:" .. h .. "<br/>"
for prime, n in pairs(utils.prime_factorization_raw(h)) do
for prime, n in pairs(utils.prime_factorization_raw(h)) do
debug_data = debug_data .. "prime:" .. prime .. "<br/>"
debug_data = debug_data .. "prime:" .. prime .. "<br/>"
Line 69: Line 68:


local numer = h / utils._gcd(h, root)
local numer = h / utils._gcd(h, root)
debug_data = debug_data .. "numerator:" .. numer .. "<br/>"
local odd = numer
local odd = numer
while odd % 2 == 0 do
while odd % 2 == 0 do
odd = odd / 2
odd = odd / 2
end
end
debug_data = debug_data .. "odd:" .. odd .. "<br/>"
if odd > odd_limit then
if odd > odd_limit then
odd_limit = odd
odd_limit = odd