Module:Powharmonic series: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) No edit summary |
ArrowHead294 (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
function p.powharmonic(frame) | function p.powharmonic(frame) | ||
local | local n = tonumber(frame.args["n"]) | ||
local expo = tonumber(frame.args["expo"]) | |||
local out_str = "{| class=\"wikitable\"\n" .. | local out_str = "{| class=\"wikitable\"\n" .. | ||
"|+ Intervals of the " .. p .. "-Powharmonic series\n" .. | "|+ Intervals of the " .. p .. "-Powharmonic series\n" .. | ||
| Line 19: | Line 20: | ||
local p_current = 0 | local p_current = 0 | ||
for i = 1, | for i = 1, n do | ||
p_current = 1200 * math.log(i, 2) * | p_current = 1200 * math.log(i, 2) * expo | ||
out_str = out_str .. | out_str = out_str .. | ||
"|-\n" .. | "|-\n" .. | ||
"| " .. i .. "\n" .. | "| " .. i .. "\n" .. | ||
"| " .. i .. "<sup>" .. | "| " .. i .. "<sup>" .. string.format(fmt_mul, expo) .. "</sup>\n" .. | ||
"| " .. string.format(fmt_mul, i^ | "| " .. string.format(fmt_mul, i^expo) .. "\n" .. | ||
"| " .. string.format(fmt_cent, p_current) .. "\n" .. | "| " .. string.format(fmt_cent, p_current) .. "\n" .. | ||
"| " .. string.format(fmt_cent, p_prev) .. "\n" .. | "| " .. string.format(fmt_cent, p_prev) .. "\n" .. | ||
Revision as of 12:57, 3 June 2024
- This module should not be invoked directly; use its corresponding template instead: Template:Powharmonic series.
This module generates a table showing the intervals of a powharmonic series for a given exponent, which is used to model timbres involving stretched or compressed harmonics.
| Introspection summary for Module:Powharmonic series | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {}
function p.powharmonic(frame)
local n = tonumber(frame.args["n"])
local expo = tonumber(frame.args["expo"])
local out_str = "{| class=\"wikitable\"\n" ..
"|+ Intervals of the " .. p .. "-Powharmonic series\n" ..
"! rowspan=\"2\" | Pitch #\n" ..
"! colspan=\"2\" | Frequency multiplier\n" ..
"! colspan=\"3\" | Pitch\n" ..
"|-\n" ..
"! Definition\n" ..
"! Decimal\n" ..
"! Cents\n" ..
"! Change (cents)\n" ..
"! Octave-reduced\n"
local fmt_mul = string.format(" %%+.%df", tonumber(frame.args["prec"]))
local fmt_cent = " %+.2f"
local p_prev = 0
local p_current = 0
for i = 1, n do
p_current = 1200 * math.log(i, 2) * expo
out_str = out_str ..
"|-\n" ..
"| " .. i .. "\n" ..
"| " .. i .. "<sup>" .. string.format(fmt_mul, expo) .. "</sup>\n" ..
"| " .. string.format(fmt_mul, i^expo) .. "\n" ..
"| " .. string.format(fmt_cent, p_current) .. "\n" ..
"| " .. string.format(fmt_cent, p_prev) .. "\n" ..
"| " .. string.format(fmt_cent, math.fmod(p_current, 1200)) .. "\n"
p_prev = p_current
end
out_str = out_str .. "|}"
return out_str
end
return p