Module:Harmonics intro: Difference between revisions
Created page with "-- Module:Harmonics intro -- Generates the opening sentences of the "Harmonics n–2n" and "Subharmonics n–2n" pages. -- Called through Template:Harmonics intro and Template:Subharmonics intro. local p = {} local getArgs = require("Module:Arguments").getArgs local EN_DASH = "–" -- "n:(n+1):…:2n", written out in full for small n local function chord(lo, hi) if hi - lo <= 7 then local t = {} for i = lo, hi do t[#t + 1] = i end return table.concat(t, ":"..." |
Formatting, skip 2 |
||
| Line 51: | Line 51: | ||
out[#out + 1] = string.format( | out[#out + 1] = string.format( | ||
"%s%s is the scale formed by the [[subharmonic]]s %d through %d of the [[subharmonic series]], that is, the ratios %d/%d, %d/%d, …, %d/%d above the root. ", | "%s%s is the scale formed by the [[subharmonic]]s %d through %d of the [[subharmonic series]], that is, the ratios %d/%d, %d/%d, …, %d/%d above the root. ", | ||
bold, aka, n, 2 * n, 2 * n, 2 * n, 2 * n, 2 * n - 1, 2 * n, n) | bold, | ||
aka, | |||
n, | |||
2 * n, | |||
2 * n, | |||
2 * n, | |||
2 * n, | |||
2 * n - 1, | |||
2 * n, | |||
n | |||
) | |||
else | else | ||
out[#out + 1] = string.format( | out[#out + 1] = string.format( | ||
"%s%s is the [[Harmonic series#Segments|harmonic segment]] %d::%d, consisting of harmonics %d through %d (%s) and spanning one octave above the root. ", | "%s%s is the [[Harmonic series#Segments|harmonic segment]] %d::%d, consisting of harmonics %d through %d (%s) and spanning one octave above the root. ", | ||
bold, aka, n, 2 * n, n, 2 * n, chord(n, 2 * n)) | bold, | ||
aka, | |||
n, | |||
2 * n, | |||
n, | |||
2 * n, | |||
chord(n, 2 * n) | |||
) | |||
end | end | ||
-- second sentence: mode name | -- second sentence: mode name | ||
out[#out + 1] = string.format("It is also called mode %d of the %s series. ", n, sub and "subharmonic" or "harmonic") | out[#out + 1] = | ||
string.format("It is also called mode %d of the %s series. ", n, sub and "subharmonic" or "harmonic") | |||
-- inverse | -- inverse | ||
if page_exists(twin_title) then | if n ~= 2 and page_exists(twin_title) then -- 2–4 is its own inverse | ||
out[#out + 1] = string.format("Its inverse is [[%s]]. ", twin_title) | out[#out + 1] = string.format("Its inverse is [[%s]]. ", twin_title) | ||
end | end | ||