Module:Harmonics in equal: Difference between revisions

At least this part should work
ArrowHead294 (talk | contribs)
No edit summary
Line 5: Line 5:
local function map(p, steps, num, denom)
local function map(p, steps, num, denom)
local s = math.log(p) / math.log(num/denom)
local s = math.log(p) / math.log(num/denom)
return math.floor(s*steps + .5)
return math.floor(s * steps + .5)
end
end
-- check consistency for 9, 15 and 21
-- check consistency for 9, 15 and 21
Line 16: Line 16:
local p21 = map(21, steps, num, denom)
local p21 = map(21, steps, num, denom)
return (p9 == 2*p3) and (p15 == p3+p5) and (p21 == p3+p7)
return (p9 == 2 * p3) and (p15 == p3 + p5) and (p21 == p3 + p7)
end
end


Line 43: Line 43:
ev = math.floor(v + .5)
ev = math.floor(v + .5)
table.insert(tpri, '' .. p)
table.insert(tpri, '' .. p)
table.insert(tabs, string.format(fmt_abs, 1200 * equave * (ev - v ) / steps))
table.insert(tabs, string.format(fmt_abs, 1200 * equave * (ev - v ) / steps):gsub("-", "−"))
table.insert(trel, string.format(fmt_rel, 100 * (ev - v)))
table.insert(trel, string.format(fmt_rel, 100 * (ev - v)):gsub("-", "−"))
if reduction then
if reduction then
table.insert(tdeg, '' .. ev .. '<br>('.. ev % steps .. ')')
table.insert(tdeg, '' .. ev:gsub("-", "&minus;") .. '<br>('.. tostring(ev % steps):gsub("-", "&minus;") .. ')')
else
else
table.insert(tdeg, '' .. ev)
table.insert(tdeg, '' .. ev:gsub("-", "&minus;"))
end
end
end
end
local titleMarkup = ''
local titleMarkup = ''
if title then
if title then
titleMarkup = '|-\n|+ style=\"white-space: nowrap;" | ' .. title .. '\n'
titleMarkup = '|-\n|+ style=\"white-space: nowrap; font-size: 110%;" | ' .. title .. '\n'
end
end