Module:EDO intro
Jump to navigation
Jump to search
Documentation transcluded from /doc
Note: Do not invoke this module directly; use the corresponding template instead: Template:EDO intro.
Documentation transcluded from /doc
Note: Do not invoke this module directly; use the corresponding template instead: Template:EDO intro.
local ord = require("Module:Ordinal")
local utils = require("Module:Utils")
local p = {}
function p.edo_intro(ed)
ed = ed or 12
-- Exactly or about?
-- Check up to three significant figures
local edostep_size = 1200 / ed
local edostep_size_rounded = utils._round(edostep_size, 3)
local edostep_text = " of " .. (edostep_size - edostep_size_rounded == 0 and "exactly " or "about ") .. edostep_size_rounded .. "⁠ ⁠[[¢]] each."
local ordinal = ord._ordinal(ed)
local intro_text = string.format("'''%d equal divisions of the octave''' (abbreviated '''%dedo'''),", ed, ed)
intro_text = intro_text
.. string.format(
" or '''%d-tone equal temperament''' ('''%dtet'''), '''%d equal temperament''' ('''%det''') when viewed under a [[regular temperament]] perspective, ",
ed,
ed,
ed,
ed
)
intro_text = intro_text
.. string.format(" is the [[tuning system]] that divides the [[octave]] into %d [[equal]] parts", ed)
intro_text = intro_text .. edostep_text
intro_text = intro_text
.. string.format(
" Each step represents a [[frequency ratio]] of 2<sup>1/%d</sup>, or the %s root of 2.",
ed,
ed,
ordinal
)
return intro_text
end
-- Parse edo from text
function p.parse(unparsed)
unparsed = unparsed or "12edo"
local parsed = unparsed:match("^(%d+)edo$") or unparsed:match("^(%d+)$")
return parsed
end
function p.edo_intro_frame(frame)
local edo = tonumber(p.parse(frame.args["EDO"]))
return frame:preprocess(p.edo_intro(edo))
end
return p