Module:Infobox chord: Difference between revisions
No edit summary |
add stepwise intervals |
||
| Line 54: | Line 54: | ||
local otonal_odd_limit = 1 | local otonal_odd_limit = 1 | ||
local root_interval_links = {} | local root_interval_links = {} | ||
local step_interval_links = {} | |||
local root_cents_steps = {} | local root_cents_steps = {} | ||
for i, h in ipairs(harmonics) do | for i, h in ipairs(harmonics) do | ||
| Line 80: | Line 81: | ||
local denom = root / gcd | local denom = root / gcd | ||
table.insert(root_interval_links, "[[" .. numer .. "/" .. denom .. "]]") | table.insert(root_interval_links, "[[" .. numer .. "/" .. denom .. "]]") | ||
-- compute ratio of this harmonic relative to the previous | |||
if i > 1 then | |||
local prev = harmonics[i-1] | |||
local step_gcd = utils._gcd(h, prev) | |||
local step_numer = h / step_gcd | |||
local step_denom = prev / step_gcd | |||
table.insert(step_interval_links, "[[" .. step_numer .. "/" .. step_denom .. "]]") | |||
end | |||
local cents_ln2 = 1731.234 | local cents_ln2 = 1731.234 | ||
| Line 146: | Line 156: | ||
table.insert(infobox_data, {"Intervals from root", table.concat(root_interval_links, " – ")}) | table.insert(infobox_data, {"Intervals from root", table.concat(root_interval_links, " – ")}) | ||
table.insert(infobox_data, {"Cents from root", table.concat(root_cents_steps, " ")}) | table.insert(infobox_data, {"Cents from root", table.concat(root_cents_steps, " ")}) | ||
table.insert(infobox_data, {"Step intervals", table.concat(step_interval_links, " , ")}) | |||
if prime_limit < 96 then | if prime_limit < 96 then | ||