Module:Harmonics intro: Difference between revisions

Sintel (talk | contribs)
phrasing
Try new intro, discussed in XA Discord
Line 1: Line 1:
-- Module:Harmonics intro
-- Module: Harmonics intro
-- Generates the opening sentences of the "Harmonics n–2n" and "Subharmonics n–2n" pages.
-- Generates the opening sentences of the "Harmonics n–2n" and "Subharmonics n–2n" pages.
-- Called through Template:Harmonics intro and Template:Subharmonics intro.
-- Called through Template: Harmonics intro and Template: Subharmonics intro.
local p = {}
local p = {}
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
Line 7: Line 7:
local EN_DASH = "–"
local EN_DASH = "–"


-- "n:(n+1):…:2n", written out in full for small n
-- "n:(n + 1):…:2n", written out in full for small n
local function chord(lo, hi)
local function chord(lo, hi)
if hi - lo <= 7 then
if hi - lo <= 7 then
Line 27: Line 27:
local n = tonumber(args[1] or args.n)
local n = tonumber(args[1] or args.n)
if not n or n < 1 or n ~= math.floor(n) then
if not n or n < 1 or n ~= math.floor(n) then
return '<strong class="error">Template:Harmonics intro requires a positive integer, e.g. <code>{{Harmonics intro|12}}</code>.</strong>'
return '<strong class="error">Template: Harmonics intro requires a positive integer, e.g. <code>{{Harmonics intro|12}}</code>.</strong>'
end
end
local range = n .. EN_DASH .. 2 * n
local range = n .. EN_DASH .. 2 * n
Line 38: Line 38:
if sub then
if sub then
out[#out + 1] = string.format(
out[#out + 1] = string.format(
"The '''%s''' are the [[subharmonic]]s %d through %d of the [[subharmonic series]]. Above the root they form the ratios %d/%d, %d/%d, …, %d/%d and span one octave. ",
"The '''%s''' are a scale that consists of [[subharmonic]]s %d through %d of the [[subharmonic series]]. Above the root they form the ratios %d/%d, %d/%d, …, %d/%d and repeat at the octave. " ..
"Used as a [[tuning system]], it is also called '''%difdo'''. ",
phrase,
phrase,
n,
n, 2 * n,
2 * n,
2 * n, 2 * n,
2 * n,
2 * n, 2 * n - 1,
2 * n,
2 * n, n,  
2 * n,
2 * n - 1,
2 * n,
n
n
)
)
Line 52: Line 50:
else
else
out[#out + 1] = string.format(
out[#out + 1] = string.format(
"The '''[[Harmonic series#Segments|harmonic segment]] %d::%d''' (also '''%s''') consists of harmonics %d through %d (%s) and spans one octave above the root. ",
"The '''%s''' (also '''harmonic series segment %d::%d''' or '''harmonic series mode %d''') are a scale that consists of harmonics %d through %d (%s) and repeats at the [[octave]]. " ..
n,
"Used as a [[tuning system]], it is also called '''%dafdo'''. ",
2 * n,
phrase,  
phrase,
n, 2 * n, n, n, 2 * n,  
n,
chord(n, 2 * n), n
2 * n,
chord(n, 2 * n)
)
)
out[#out + 1] = string.format("Used as a scale, it is also called mode %d of the harmonic series. ", n)
out[#out + 1] = string.format("Used as a scale, it is also called mode %d of the harmonic series. ", n)