Module:Infobox chord: Difference between revisions
increase spacing in step intervals |
add minimal genus of chord to infobox |
||
| Line 57: | Line 57: | ||
local root_cents_steps = {} | local root_cents_steps = {} | ||
local step_cents = {} | local step_cents = {} | ||
local genus = {} | |||
for i, h in ipairs(harmonics) do | for i, h in ipairs(harmonics) do | ||
-- compute LCM of all harmonics to use as the denominator in utonal form, if needed | -- compute LCM of all harmonics to use as the denominator in utonal form, if needed | ||
| Line 70: | Line 71: | ||
end | end | ||
-- increase prime limit for this harmonic, if needed | -- increase prime limit for this harmonic, if needed, | ||
-- and increase genus factors if needed | |||
for prime, n in pairs(utils.prime_factorization_raw(h)) do | for prime, n in pairs(utils.prime_factorization_raw(h)) do | ||
if prime > prime_limit then | if prime > prime_limit then | ||
prime_limit = prime | prime_limit = prime | ||
end | |||
local prev = genus[prime] or 0 | |||
if n > prev then | |||
genus[prime] = n | |||
end | end | ||
end | end | ||
| Line 138: | Line 144: | ||
end | end | ||
end | end | ||
end | |||
-- genus | |||
local genus_terms = {} | |||
local primes = {} | |||
for prime, _ in pairs(genus) do | |||
table.insert(primes, prime) | |||
end | |||
table.sort(primes) | |||
for i, prime in ipairs(primes) do | |||
local exponent = genus[prime] | |||
table.insert(genus_terms, prime .. "<sup>" .. exponent .. "</sup>") | |||
end | end | ||
| Line 162: | Line 180: | ||
table.insert(infobox_data, {"Step cents", table.concat(step_cents, ", ")}) | table.insert(infobox_data, {"Step cents", table.concat(step_cents, ", ")}) | ||
table.insert(infobox_data, {"[[Genus]]", table.concat(genus_terms, " ⋅ ")}) | |||
if prime_limit < 96 then | if prime_limit < 96 then | ||
table.insert(infobox_data, {"[[Prime limit]]", "[[" .. prime_limit .. "-limit|" .. prime_limit .. "]]"}) | table.insert(infobox_data, {"[[Prime limit]]", "[[" .. prime_limit .. "-limit|" .. prime_limit .. "]]"}) | ||