Module:MOS intro: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Removed extra "every"
ArrowHead294 (talk | contribs)
mNo edit summary
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local mos = require('Module:MOS')
local rat = require('Module:Rational')
local utils = require('Module:Utils')
local et = require('Module:ET')
local tip = require('Module:Template input parse')
local p = {}
local p = {}
local et = require("Module:ET")
local mos = require("Module:MOS")
local rat = require("Module:Rational")
local tamnams = require("Module:TAMNAMS")
local tip = require("Module:Template input parse")
local utils = require("Module:Utils")
local yesno = require("Module:Yesno")
-- TODO:
-- - Possible cleanup/rewording
-- - Possible official deprecation of other names; focus should be on what a mos
--  is, not what it's called.


-- Helper function
-- Helper function
Line 194: Line 202:
function p._mos_intro(input_mos, other_names)
function p._mos_intro(input_mos, other_names)
local input_mos = input_mos or mos.new(5, 5, 3)
local input_mos = input_mos or mos.new(5, 5, 3)
local other_names = other_names or ""
local other_names = ""
-- Scale sig
-- Scale sig
Line 200: Line 208:
-- Tamnams names, if any
-- Tamnams names, if any
local tamnams_name = mos.tamnams_name[scale_sig] or ""
local tamnams_name = tamnams.lookup_name(input_mos) or ""
-- Parsed names
-- Parsed names
Line 240: Line 248:
-- Add repetition
-- Add repetition
if n == 1 then
if n == 1 then
intro = intro .. ", repeating every " .. (equave_in_cents == 1200 and "[[octave]]." or string.format(" interval of [[%s]] (%.1f¢).", equave_as_ratio, equave_in_cents, round))
intro = intro .. ", repeating every " .. (equave_in_cents == 1200 and "[[octave]]." or string.format(" interval of [[%s]] (%.1f{{cent}}).", equave_as_ratio, equave_in_cents, round))
else
else
intro = intro .. string.format(", with a [[period]] of %d large %s", nL/n, (nL/n == 1 and "step" or "steps"))
intro = intro .. string.format(", with a [[period]] of %d large %s", nL/n, (nL/n == 1 and "step" or "steps"))
intro = intro .. string.format(" and %d small %s", ns/n, (ns/n == 1 and "step" or "steps"))
intro = intro .. string.format(" and %d small %s", ns/n, (ns/n == 1 and "step" or "steps"))
intro = intro .. string.format(" that repeats every %.1f¢", period_in_cents)
intro = intro .. string.format(" that repeats every %.1f{{cent}}", period_in_cents)
intro = intro .. (n == 2 and ", or twice every" or string.format(", or %d times every", n)) .. (equave_in_cents == 1200 and " octave." or string.format(" interval of [[%s]] (%.1f¢).", equave_as_ratio, equave_in_cents, round))
intro = intro .. (n == 2 and ", or twice every" or string.format(", or %d times every", n)) .. (equave_in_cents == 1200 and " octave." or string.format(" interval of [[%s]] (%.1f{{cent}}).", equave_as_ratio, equave_in_cents, round))
end
end
Line 275: Line 283:
local dark_gen_max_r = tostring(utils._round_dec(dark_gen_max, round))
local dark_gen_max_r = tostring(utils._round_dec(dark_gen_max, round))
intro = intro .. string.format(" [[generator|Generators]] that produce this scale range from %to %, or from %to %.", bright_gen_min_r, bright_gen_max_r, dark_gen_min_r, dark_gen_max_r)
intro = intro .. string.format(" [[Generator]]s that produce this scale range from %s{{cent}} to %s{{cent}}, or from %s{{cent}} to %s{{cent}}.", bright_gen_min_r, bright_gen_max_r, dark_gen_min_r, dark_gen_max_r)
-- Rothenberg propriety (rothenprop) info
-- Rothenberg propriety (rothenprop) info
Line 285: Line 293:
return intro
return intro
end
end


Line 291: Line 298:
function p.mos_intro_frame(frame)
function p.mos_intro_frame(frame)
-- Get and parse the the mos's scale signature, in the form xL ys or xL ys <p/q>
-- Get and parse the the mos's scale signature, in the form xL ys or xL ys <p/q>
local input_mos = mos.parse(frame.args['Scale Signature']) or mos.new(5, 2, 2)
local input_mos = mos.parse(frame.args["Scale Signature"]) or mos.new(5, 2, 2)
local other_names = frame.args['Other Names'] or ""
local other_names = frame.args["Other Names"] or ""
local depparams = (other_names ~= "" and " [[Category:Pages with deprecated parameters]]" or "")
    local result = p._mos_intro(input_mos, other_names) .. depparams
    local debugg = yesno(frame.args["debug"])
   
    -- Debugger option
    if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return p._mos_intro(input_mos, other_names)
return frame:preprocess(result)
end
end


return p
return p