Module:Sharpness documentation: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 8: Line 8:
local note = frame.args["note"] or ""
local note = frame.args["note"] or ""
local notation = frame.args["notation"]
local notation = frame.args["notation"]
local out_str = "This template is \"" .. c .. "\"used "
if c == nil then
if c == nil then
c = ""
c = ""
end
end
local out_str = "This template is used "
if (d == "flat" or d == "flat") then
if (d == "flat" or d == "flat") then
Line 34: Line 35:
out_str = out_str .. "."
out_str = out_str .. "."
if notation == "" and c == "" then
if notation == "" then
if s >= 3 then
if s >= 3 then
out_str = out_str .. " The symbol set is based on [[ups and downs notation]] and comprises "
if c == "" then
.. (s % 2 == 0
out_str = out_str .. " The symbol set is based on [[ups and downs notation]] and comprises "
and "sharps, flats, naturals, and Stein–Zimmerman [[24edo#Notation|quarter tone]] accidentals "
.. (s % 2 == 0
or "sharps, flats, and naturals ")
and "sharps, flats, naturals, and Stein–Zimmerman [[24edo#Notation|quarter tone]] accidentals "
or "sharps, flats, and naturals ")
out_str = out_str .. "with arrows from [[Helmholtz–Ellis notation]]."
out_str = out_str .. "with arrows from [[Helmholtz–Ellis notation]]."
elseif c == "a" or c == "A" then
out_str = out_str .. " The symbol set is based on [[ups and downs notation]] using separate arrows."
end
end
end
else
else

Revision as of 21:27, 8 February 2025

Module documentation[view] [edit] [history] [purge]
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 
Functions provided (1)
Line Function Params
3 main (invokable) (frame)
Lua modules required (0)
Variable Module Functions used

No function descriptions were provided. The Lua code may have further information.

See also


local p = {}

function p.main(frame)
	local page_name = string.lower(frame:preprocess("{{PAGENAME}}"))
	local d, b, c = page_name:match("%-(%a*)(%d+)(%a*)")
	local s = tonumber(b)
	local sc = s * 12
	local note = frame.args["note"] or ""
	local notation = frame.args["notation"]
	
	if c == nil then
		c = ""
	end
	
	local out_str = "This template is used "
	
	if (d == "flat" or d == "flat") then
		s = -s
	end
	
	if s == 0 then
		out_str = out_str
			.. "for {{EDOs| 7, 14, 21, 28, and 35 }} [[equal divisions of the octave]]. "
			.. "Since these tunings temper out the 3-limit augmented unison (the Pythagorean apotome [[2187/2048]]), "
			.. "the traditional sharps and flats have no effect on the pitch."
	else
		out_str = out_str
			.. "for [[EDO]]s 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
				if c == "" then
					out_str = out_str .. " The symbol set is based on [[ups and downs notation]] and comprises "
					.. (s % 2 == 0
						and "sharps, flats, naturals, and Stein&ndash;Zimmerman [[24edo#Notation|quarter tone]] accidentals "
						or "sharps, flats, and naturals ")
					
					out_str = out_str .. "with arrows from [[Helmholtz&ndash;Ellis notation]]."
				elseif c == "a" or c == "A" then
					out_str = out_str .. " The symbol set is based on [[ups and downs notation]] using separate arrows."
				end
			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<h3>Parameters</h3>\n"
				.. "Passing <code>{{pipe}}"
				.. sc
				.. "</code> will change '''Step offset''' to '''Semitones''' in the case of [["
				.. sc .. "edo]]"
				.. ((s >= 2) and {", since " .. sc .. "edo is a superset of [[12edo]]."} or {"."})[1]
		end
		
		if s >= 3 then
			out_str = out_str
				.. "\n\n<h3>See also</h3>\n"
				.. "* [[Alternative symbols for ups and downs notation]]"
		end
	end
	
	local debugg = frame.args["debug"]
	return frame:preprocess(debugg == "true" and "<pre>" .. out_str .. "</pre>" or out_str)
end

return p