Module:Powharmonic series: Difference between revisions

ArrowHead294 (talk | contribs)
Condense
ArrowHead294 (talk | contribs)
mNo edit summary
Line 4: Line 4:
     local n = tonumber(frame.args["n"])
     local n = tonumber(frame.args["n"])
     local expo = tonumber(frame.args["expo"])
     local expo = tonumber(frame.args["expo"])
     local out_str =  
     local out_str = "{| class=\"wikitable center-all\"\n"
    "{| class=\"wikitable center-all\"\n" ..
    .. "|+ style=\"font-size: 105%;\" | Intervals of the " .. expo .. "-Powharmonic series\n"
    "|+ Intervals of the " .. expo .. "-Powharmonic series\n" ..
    .. "! rowspan=\"2\" | Pitch !! colspan=\"2\" | Frequency multiplier !! colspan=\"3\" | Pitch\n"
    "! rowspan=\"2\" | Pitch !! colspan=\"2\" | Frequency multiplier !! colspan=\"3\" | Pitch\n" ..
    .. "|-\n"
    "|-\n" ..
    .. "! Definition !! Decimal !! [[Cent]]s !! Change (cents) !! Octave-reduced (cents)"
    "! Definition !! Decimal !! [[Cent]]s !! Change (cents) !! Octave-reduced (cents)\n"
    .. "\n"
     local fmt_cent = string.format("%%.%df", tonumber(frame.args["prec"]))
     local fmt_cent = string.format("%%.%df", tonumber(frame.args["prec"]))
     local p_prev = 0
     local p_prev = 0
Line 16: Line 16:
     for i = 1, n do
     for i = 1, n do
         p_current = 1200 * math.log(i) / math.log(2) * expo
         p_current = 1200 * math.log(i) / math.log(2) * expo
         out_str = out_str ..
         out_str = out_str
            "|-\n" ..
            .. "|-\n"
            "| " .. i ..
            .. "| ".. i
            "|| " .. i .. "<sup>" .. expo .. "</sup>" ..
            .. " || " .. i .. "<sup>" .. expo .. "</sup>"
            "|| " .. string.format(fmt_cent, i^expo) ..
            .. " || " .. string.format(fmt_cent, i^expo)
            "|| " .. string.format(fmt_cent, p_current) ..
            .. " || " .. string.format(fmt_cent, p_current)
            "|| " .. string.format(fmt_cent, p_current - p_prev) ..
            .. " || " .. string.format(fmt_cent, p_current - p_prev)
            "|| " .. string.format(fmt_cent, math.fmod(p_current, 1200)) .. "\n"
            .. " || " .. string.format(fmt_cent, math.fmod(p_current, 1200))
            .. "\n"
         p_prev = p_current
         p_prev = p_current
     end
     end