Module:Sharpness documentation: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 23: | Line 23: | ||
end | end | ||
local | local result = "This template is used " | ||
if s == 0 then | if s == 0 then | ||
-- Sharp-0 EDOs (lower 5 multiples of 7) are redundant, take care of that right away | -- Sharp-0 EDOs (lower 5 multiples of 7) are redundant, take care of that right away | ||
result = result | |||
.. "for {{EDOs| 7, 14, 21, 28, and 35 }} [[equal divisions of the octave]]. " | .. "for {{EDOs| 7, 14, 21, 28, and 35 }} [[equal divisions of the octave]]. " | ||
.. "Since these tunings temper out the 3-limit augmented unison ([[2187/2048]], known as the Pythagorean apotome), " | .. "Since these tunings temper out the 3-limit augmented unison ([[2187/2048]], known as the Pythagorean apotome), " | ||
| Line 34: | Line 34: | ||
else | else | ||
-- Otherwise | -- Otherwise | ||
result = result | |||
.. "for [[edo]]s where a sharp " | .. "for [[edo]]s where a sharp " | ||
.. ((s < 0) and "lowers" or "raises") | .. ((s < 0) and "lowers" or "raises") | ||
| Line 42: | Line 42: | ||
if math.abs(s) ~= 1 then | if math.abs(s) ~= 1 then | ||
result = result .. "s" | |||
end | end | ||
result = result .. "." | |||
if notation == "" then | if notation == "" then | ||
result = result .. " This symbol set " | |||
if math.abs(s) == 1 then | if math.abs(s) == 1 then | ||
result = result .. "is identical to standard notation." | |||
else | else | ||
if extension == "" then | if extension == "" then | ||
if math.abs(s) == 2 then | if math.abs(s) == 2 then | ||
-- If a sharp raises by two steps | -- If a sharp raises by two steps | ||
result = result | |||
.. "comprises sharps, flats, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals." | .. "comprises sharps, flats, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals." | ||
else | else | ||
-- Otherwise (if a sharp raises by three or more steps) | -- Otherwise (if a sharp raises by three or more steps) | ||
result = result | |||
.. "is based on [[ups and downs notation]] and comprises sharps, flats, " | .. "is based on [[ups and downs notation]] and comprises sharps, flats, " | ||
.. (s % 2 == 0 and "naturals, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals " or "and naturals ") | .. (s % 2 == 0 and "naturals, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals " or "and naturals ") | ||
| Line 67: | Line 67: | ||
elseif extension == "a" or extension == "A" then | elseif extension == "a" or extension == "A" then | ||
-- Extension for modern-style ups and downs | -- Extension for modern-style ups and downs | ||
result = result .. "is based on [[ups and downs notation]] using separate arrows." | |||
end | end | ||
end | end | ||
else | else | ||
result = result .. " It is based on " .. notation .. "." | |||
end | end | ||
-- display custom notes | -- display custom notes | ||
if note or aux_note then | if note or aux_note then | ||
result = result .. " " .. note ..(aux_note ~= "" and "\n\n" .. aux_note or "") | |||
end | end | ||
| Line 83: | Line 83: | ||
local n_edo = s * 12 | local n_edo = s * 12 | ||
result = result | |||
.. "\n\n<h3>Parameters</h3>\n" | .. "\n\n<h3>Parameters</h3>\n" | ||
.. "Passing in <code>".. n_edo .. "</code> as a single unnamed parameter will change " | .. "Passing in <code>".. n_edo .. "</code> as a single unnamed parameter will change " | ||
.. "'''Step offset''' to '''Semitones''' in the case of [[" .. n_edo .. "edo]]" | .. "'''Step offset''' to '''Semitones''' in the case of [[" .. n_edo .. "edo]]" | ||
if s >= 2 then | if s >= 2 then | ||
result = result .. ", since " .. n_edo .. "edo is a superset of [[12edo]]" | |||
end | end | ||
result = result .. "." | |||
end | end | ||
| Line 97: | Line 97: | ||
local basic = "Template:Sharpness-" .. typ .. value | local basic = "Template:Sharpness-" .. typ .. value | ||
local basic_suf = basic .. "-" .. suffix | local basic_suf = basic .. "-" .. suffix | ||
result = result .. "\n\n<h3>See also</h3>\n" | |||
.. "* [[Alternative symbols for ups and downs notation]]\n" | .. "* [[Alternative symbols for ups and downs notation]]\n" | ||
if (extension == "a" or extension == "A") then | if (extension == "a" or extension == "A") then | ||
-- If the template shows separate arrows | -- If the template shows separate arrows | ||
result = result | |||
.. "* [[{{#ifexist: " .. basic_suf .. "|" .. basic_suf .. "|" .. basic .. "}}]] – " | .. "* [[{{#ifexist: " .. basic_suf .. "|" .. basic_suf .. "|" .. basic .. "}}]] – " | ||
.. (s == 2 | .. (s == 2 | ||
| Line 109: | Line 109: | ||
else | else | ||
-- If the template shows integrated (HEJI-like) arrows | -- If the template shows integrated (HEJI-like) arrows | ||
result = result .. "{{#ifexist: " .. basic .. "a|* [[" .. basic .. "a]] – " | |||
.. "an alternate version of this template that shows separate arrows.\n|}}" | .. "an alternate version of this template that shows separate arrows.\n|}}" | ||
if string.lower(suffix) ~= "" then | if string.lower(suffix) ~= "" then | ||
-- If we are on a different version of a template (e.g. "extended" ones that show more arrows than the minimum) | -- If we are on a different version of a template (e.g. "extended" ones that show more arrows than the minimum) | ||
result = result .. "{{#ifexist: ".. basic .. "|* [[" .. basic .. "]] – " | |||
.. "the basic version of this template.|}}" | .. "the basic version of this template.|}}" | ||
else | else | ||
-- Otherwise, add an additional note for possible extended versions, if they exist | -- Otherwise, add an additional note for possible extended versions, if they exist | ||
if s == 3 or s == 5 then | if s == 3 or s == 5 then | ||
result = result .. "{{#ifexist: " .. basic .. "-extended|* [[" .. basic .. "-extended]] – " | |||
.. "an alternate version of this template that includes " | .. "an alternate version of this template that includes " | ||
| Line 125: | Line 125: | ||
-- Sharp-3 EDOs normally only need single arrows, but note that | -- Sharp-3 EDOs normally only need single arrows, but note that | ||
-- sometimes double arrows may be needed | -- sometimes double arrows may be needed | ||
result = result .. "double" | |||
elseif s == 5 then | elseif s == 5 then | ||
-- Sharp-5 EDOs normally need double arrows, and note that sometimes | -- Sharp-5 EDOs normally need double arrows, and note that sometimes | ||
-- triple arrows may be needed | -- triple arrows may be needed | ||
result = result .. "triple" | |||
end | end | ||
result = result .. " arrows.|}}" | |||
end | end | ||
end | end | ||
| Line 140: | Line 140: | ||
local is_debug = yesno(frame.args["debug"]) | local is_debug = yesno(frame.args["debug"]) | ||
return frame:preprocess(is_debug == true and "<pre>" .. | return frame:preprocess(is_debug == true and "<pre>" .. result .. "</pre>" or result) | ||
end | end | ||
return module | return module | ||
Revision as of 14:02, 11 March 2025
- This module should not be invoked directly; use its corresponding template instead: Template:Sharpness documentation.
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).
By default, it handles standard sharps and flats, quarter-tone accidentals, and ups and downs notation.
| Introspection summary for Module:Sharpness documentation | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| ||||||||||||
No function descriptions were provided. The Lua code may have further information.
See also
local yesno = require("Module:yesno")
local module = {}
function module.main(frame)
local in_str = frame.args["input"]
local note = frame.args["note"] or ""
local aux_note = frame.args["auxnote"] or ""
local notation = frame.args["notation"] or ""
-- typ: "sharp" or "flat"
-- value: Absolute value of sharpness (the "n" as in sharp-n and flat-n)
-- extension: Used for identifying alternative symbol set
local typ, value, extension, suffix = string.lower(in_str):match("%-(%a*)(%d+)(%a*)-?(%a*)")
-- Signed sharpness
local s = tonumber(value)
if typ == "flat" then
s = -s
end
if extension == nil then
extension = ""
end
local result = "This template is used "
if s == 0 then
-- Sharp-0 EDOs (lower 5 multiples of 7) are redundant, take care of that right away
result = result
.. "for {{EDOs| 7, 14, 21, 28, and 35 }} [[equal divisions of the octave]]. "
.. "Since these tunings temper out the 3-limit augmented unison ([[2187/2048]], known as the Pythagorean apotome), "
.. "going up seven fifths brings one back to the root note, and as such "
.. "the traditional sharps and flats are redundant and cannot raise or lower the pitch."
else
-- Otherwise
result = result
.. "for [[edo]]s where a sharp "
.. ((s < 0) and "lowers" or "raises")
.. " by "
.. math.abs(s)
.. " step"
if math.abs(s) ~= 1 then
result = result .. "s"
end
result = result .. "."
if notation == "" then
result = result .. " This symbol set "
if math.abs(s) == 1 then
result = result .. "is identical to standard notation."
else
if extension == "" then
if math.abs(s) == 2 then
-- If a sharp raises by two steps
result = result
.. "comprises sharps, flats, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals."
else
-- Otherwise (if a sharp raises by three or more steps)
result = result
.. "is based on [[ups and downs notation]] and comprises sharps, flats, "
.. (s % 2 == 0 and "naturals, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals " or "and naturals ")
.. "with arrows from [[Helmholtz–Ellis notation]]."
end
elseif extension == "a" or extension == "A" then
-- Extension for modern-style ups and downs
result = result .. "is based on [[ups and downs notation]] using separate arrows."
end
end
else
result = result .. " It is based on " .. notation .. "."
end
-- display custom notes
if note or aux_note then
result = result .. " " .. note ..(aux_note ~= "" and "\n\n" .. aux_note or "")
end
-- Display the note about supersets of 12edo for sharpness-1 and above and set the edo number for supersets of 12edo
if s >= 1 then
local n_edo = s * 12
result = result
.. "\n\n<h3>Parameters</h3>\n"
.. "Passing in <code>".. n_edo .. "</code> as a single unnamed parameter will change "
.. "'''Step offset''' to '''Semitones''' in the case of [[" .. n_edo .. "edo]]"
if s >= 2 then
result = result .. ", since " .. n_edo .. "edo is a superset of [[12edo]]"
end
result = result .. "."
end
-- Display a "see also" section for sharpness-2 and above
if s >= 2 or s <= -2 then
local basic = "Template:Sharpness-" .. typ .. value
local basic_suf = basic .. "-" .. suffix
result = result .. "\n\n<h3>See also</h3>\n"
.. "* [[Alternative symbols for ups and downs notation]]\n"
if (extension == "a" or extension == "A") then
-- If the template shows separate arrows
result = result
.. "* [[{{#ifexist: " .. basic_suf .. "|" .. basic_suf .. "|" .. basic .. "}}]] – "
.. (s == 2
and "uses Stein–Zimmerman quarter tone accidentals."
or "the classic version of this template that shows arrows attached to standard accidentals.")
else
-- If the template shows integrated (HEJI-like) arrows
result = result .. "{{#ifexist: " .. basic .. "a|* [[" .. basic .. "a]] – "
.. "an alternate version of this template that shows separate arrows.\n|}}"
if string.lower(suffix) ~= "" then
-- If we are on a different version of a template (e.g. "extended" ones that show more arrows than the minimum)
result = result .. "{{#ifexist: ".. basic .. "|* [[" .. basic .. "]] – "
.. "the basic version of this template.|}}"
else
-- Otherwise, add an additional note for possible extended versions, if they exist
if s == 3 or s == 5 then
result = result .. "{{#ifexist: " .. basic .. "-extended|* [[" .. basic .. "-extended]] – "
.. "an alternate version of this template that includes "
if s == 3 then
-- Sharp-3 EDOs normally only need single arrows, but note that
-- sometimes double arrows may be needed
result = result .. "double"
elseif s == 5 then
-- Sharp-5 EDOs normally need double arrows, and note that sometimes
-- triple arrows may be needed
result = result .. "triple"
end
result = result .. " arrows.|}}"
end
end
end
end
end
local is_debug = yesno(frame.args["debug"])
return frame:preprocess(is_debug == true and "<pre>" .. result .. "</pre>" or result)
end
return module