Module:Harmonics in edo: Difference between revisions

Inthar (talk | contribs)
No edit summary
Inthar (talk | contribs)
mNo edit summary
Line 3: Line 3:
local function edoprox(edo, odds, title, prec)
local function edoprox(edo, odds, title, prec)
   local f = 1/edo
   local f = 1/edo
   local todd = {'! colspan="2" | Odd harmonic '}
   local todd = {'! | Odd harmonic '}
   local tabs = {'! rowspan="2" | Error \n! absolute ([[cent|¢]]) '}
   local tabs = {'! | Error \n! ([[cent|¢]]) '}
  local trel = {'! [[Relative error|relative]] (%) '}
   local tdeg = {'! | Steps ([[reduced]])'}
   local tdeg = {'! colspan="2" | Steps ([[octave reduction|reduced]])'}
   local fmt_abs = string.format(' %%+.%df', prec)
   local fmt_abs = string.format(' %%+.%df', prec)
   local fmt_rel = ' %+.0f'
   local fmt_rel = ' %+.0f'
Line 13: Line 12:
     v = s*edo
     v = s*edo
     ev = math.floor(v + .5)
     ev = math.floor(v + .5)
     table.insert(todd, ' ' .. p)
     table.insert(todd, ' ' .. p'/2')
     table.insert(tabs, string.format(fmt_abs, 1200 * (ev - v ) / edo))
     table.insert(tabs, string.format(fmt_abs, 1200 * (ev - v ) / edo))
    table.insert(trel, string.format(fmt_rel, 100 * (ev - v)))
     table.insert(tdeg, ' .. ev % edo .. ')
     table.insert(tdeg, ' ' .. ev .. ' ('.. ev % edo .. ')')
   end
   end
   local titleMarkup = ''
   local titleMarkup = ''
Line 29: Line 27:
     '|-\n' ..
     '|-\n' ..
     table.concat(tabs, '\n|') .. '\n' ..
     table.concat(tabs, '\n|') .. '\n' ..
    '|-\n' ..
table.concat(trel, '\n|') .. '\n' ..
     '|-\n' ..
     '|-\n' ..
   table.concat(tdeg, '\n|') .. '\n' ..
   table.concat(tdeg, '\n|') .. '\n' ..