Module:MOS scalesig

From Xenharmonic Wiki
Revision as of 13:28, 19 May 2025 by ArrowHead294 (talk | contribs) (Sort dependencies)
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]
This module should not be invoked directly; use its corresponding template instead: Template:MOS scalesig.

Module:MOS scalesig formats a string into a mos scale signature, with non-breaking spaces and, if non-octave, the appropriate brackets. Scale signatures can optionally be formatted as a link to the scale's wiki page.

Introspection summary for Module:MOS scalesig 
Functions provided (3)
Line Function Params
8 _mos_scalesig (main) (input_mos, is_link, is_long)
18 mos_scalesig (invokable) (frame)
30 tester none
Lua modules required (3)
Variable Module Functions used
getArgs Module:Arguments getArgs
mos Module:MOS as_long_link
as_link
as_long_string
as_string
parse
new
yesno Module:Yesno yesno

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


local p = {}

local getArgs = require("Module:Arguments").getArgs
local mos = require("Module:MOS")
local yesno = require("Module:Yesno")

-- "Main" function; calls appropriate mos-string functions
function p._mos_scalesig(input_mos, is_link, is_long)
	local is_link = yesno(is_link, false)		-- Should the the scalesig be a link?
	local is_long = yesno(is_long, false)		-- Should the scalesig be in the long form "xL ys (p/q-equivalent)"?
	
	return (is_link == true
		and (is_long and mos.as_long_link(input_mos) or mos.as_link(input_mos))
		or (is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos)))
end

-- Wrapper function
function p.mos_scalesig(frame)
	local args = getArgs(frame)
	
	local input_mos = mos.parse(args["scalesig"])
	local is_link = yesno(args["link"], false)
	local is_long = yesno(args["long"], false)
	
	local result = p._mos_scalesig(input_mos, is_link, is_long)
	local debugg = yesno(args["debug"])
	return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
end

function p.tester()
	local input_mos = mos.new(5, 2)
	return p._mos_scalesig(input_mos, true, true)
end

return p