Module:Sharpness documentation: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
Turn into module so arguments can be parsed directly from page name
 
ArrowHead294 (talk | contribs)
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}


function p.doc(frame)
function p.main(frame)
local page_name = string.lower(frame:preprocess("{{ROOTPAGENAME}}"))
local page_name = string.lower(frame:preprocess("{{ROOTPAGENAME}}"))
local d, b = page_name:match("^.*-(.*)(%d+).*$")
local d, b = page_name:match("^.*-(.*)(%d+).*$")

Revision as of 16:12, 20 September 2024

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("{{ROOTPAGENAME}}"))
	local d, b = page_name:match("^.*-(.*)(%d+).*$")
	local s = tonumber(b)
	local sc = s * 12
	local out_str = "This template is used for "
	
	if s == 0 then
		out_str = out_str
			.. "{{EDOs|7, 14, 21, 28, and 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 {"raises"} or {"lowers"})[1] .. " by " .. s .. " step"
			
		if s ~= 1 then
			out_str = out_str .. "s"
		end
		
		out_str = out_str .. "."
		
		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
		
		out_str = out_str .. frame.note
			.. "\n\n=== Parameters ===\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 direct extension of [[12edo|12-tone equal temperament]]."} or {"."})[1]
		
		if s >= 3 then
			out_str = out_str
				.. "\n\n=== See also ===\n"
				.. "* [[Alternative symbols for ups and downs notation]]"
		end
		
		return out_str
	end
end

return p