Module:Sharpness documentation
Jump to navigation
Jump to search
Documentation transcluded from /doc
Documentation transcluded from /doc
This module is used for Template:Sharpness documentation to automate information for sharpness templates (templates that show how many steps sharps or flats raise or lower by).
local p = {}
function p.main(frame)
local page_name = string.lower(frame:preprocess("{{PAGENAME}}"))
local d, b = page_name:match("%-(%a*)(%d+)")
local s = tonumber(b)
local sc = s * 12
local note = frame.args["note"] or ""
local notation = frame.args["notation"]
local out_str = "This template is used "
if (d == "flat") then
s = -s
end
if s == 0 then
out_str = out_str
.. "for [[7edo|7]], [[14edo|14]], [[21edo|21]], [[28edo|28]], and [[35edo|35]] [[EDO|equal divisions of the octave]]. Since these tunings temper out the Pythagorean apotome ([[2187/2048]]), the traditional sharps and flats have no effect on the pitch."
else
out_str = out_str
.. "where a sharp " .. ((s < 0) and {"lowers"} or {"raises"})[1] .. " by " .. math.abs(s) .. " step"
if math.abs(s) ~= 1 then
out_str = out_str .. "s"
end
out_str = out_str .. "."
if notation == "" then
if s >= 3 then
out_str = out_str .. " It is based on [[ups and downs notation]] notated using [[Helmholtz–Ellis notation|Helmholtz–Ellis]]"
if s % 2 == 0 then
out_str = out_str .. " and [[24edo#Notation|quarter tone]]"
end
out_str = out_str .. " accidentals."
end
else
out_str = out_str .. " It is based on " .. notation .. "."
end
if note then
out_str = out_str .. " " .. note
end
if s >= 1 then
out_str = out_str
.. "\n\n=== Parameters ===\n"
.. "Passing <code>|"
.. sc
.. "</code> will change '''Step Offset''' to '''Semitones''' in the case of [["
.. sc .. "edo]]"
.. ((s >= 2) and {", since " .. sc .. "edo is a direct extension of [[12edo|12-tone equal temperament]]."} or {"."})[1]
end
if s >= 3 then
out_str = out_str
.. "\n\n=== See also ===\n"
.. "* [[Alternative symbols for ups and downs notation]]"
end
end
return out_str
end
return p