Module:Infobox chord: Difference between revisions

Bcmills (talk | contribs)
mNo edit summary
Bcmills (talk | contribs)
add steps in cents; make formatting consistent for ratio and cents expressions of chord properties
Line 56: Line 56:
local step_interval_links = {}
local step_interval_links = {}
local root_cents_steps = {}
local root_cents_steps = {}
local step_cents = {}
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 81: Line 82:
local denom = root / gcd
local denom = root / gcd
table.insert(root_interval_links, "[[" .. numer .. "/" .. denom .. "]]")
table.insert(root_interval_links, "[[" .. numer .. "/" .. denom .. "]]")
local cents_ln2 = 1731.234


-- compute ratio of this harmonic relative to the previous
-- compute ratio of this harmonic relative to the previous
Line 89: Line 92:
local step_denom = prev / step_gcd
local step_denom = prev / step_gcd
table.insert(step_interval_links, "[[" .. step_numer .. "/" .. step_denom .. "]]")
table.insert(step_interval_links, "[[" .. step_numer .. "/" .. step_denom .. "]]")
table.insert(step_cents, utils._round_dec(cents_ln2 * math.log(step_numer / step_denom)) .. "¢")
end
end
local cents_ln2 = 1731.234
table.insert(root_cents_steps, utils._round_dec(cents_ln2 * math.log(numer / denom)) .. "¢")
table.insert(root_cents_steps, utils._round_dec(cents_ln2 * math.log(numer / denom)) .. "¢")
end
end
Line 155: Line 158:
end
end
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, ", ")})
table.insert(infobox_data, {"Step intervals", table.concat(step_interval_links, ", ")})
table.insert(infobox_data, {"Step cents", table.concat(step_cents, ", ")})


if prime_limit < 96 then
if prime_limit < 96 then