Module:Ups and downs sharpness

Revision as of 01:02, 23 September 2025 by Tristanbay (talk | contribs) (may work with placeholders now but I have to test it)
Module documentation[view] [edit] [history] [purge]
This module should not be invoked directly; use its corresponding template instead: Template:Ups and downs sharpness.

This module automatically creates a table with the combinations of symbols to notate a given edo using Kite's ups and downs notation.

Introspection summary for Module:Ups and downs sharpness 
Functions provided (1)
Line Function Params
11 ud_sharpness (invokable) (frame)
Lua modules required (1)
Variable Module Functions used
utils Module:Utils dependency not used

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


-- unfinished module!
local p = {}
local utils = require("Module:Utils")

-- calculate amount of steps for sharp/flat
local function sharp_n(edo)
	return (7 * math.floor((edo * math.log(3) / math.log(2)) + 0.5)) - (11 * edo) -- mapping of augmented unison
end

-- generate table
function p.ud_sharpness(frame)
	local sharp = sharp_n(frame.args["edo"])
	local tab = "{|class=\"wikitable\"\n|+\n!Step offset\n|'''0'''\n"
	for i = 1, sharp * 2 + 1 do
		if (i % sharp == 0) then
			tab = tab .. "|'''" .. i .. "'''\n"
		else
			tab = tab .. "|" .. i .. "\n"
		end
	end
	tab = tab .. "|-\n!Sharp symbol\n|rowspan=\"2\"| [[File:Heji18.svg|15px]]\n"
	for i = 1, sharp * 2 + 1 do
		tab = tab .. "|"
		if ((i - (sharp * floor(i / sharp))) / sharp) > math.floor(((i - (sharp * floor(i / sharp))) / sharp) + 0.5) then
			if (i - (sharp * floor(i / sharp))) % 5 == 4 then
				tab = tab .. "down quip "
			else
				for j = 1, (i - (sharp * floor(i / sharp))) % 5 do
					tab = tab .. "up "
				end
			end
			for j = 1, floor((i - (sharp * floor(i / sharp))) / 5) do
				tab = tab .. "quip "
			end
		else
			if ((sharp * ceil(i / sharp)) - i) % 5 == 1 then
				tab = tab .. "up quid "
			else
				for j = 1, ((sharp * ceil(i / sharp)) - i) % 5 do
					tab = tab .. "down "
				end
			end
			for j = 1, floor(((sharp * ceil(i / sharp)) - i) / 5) do
				tab = tab .. "quid "
			end
		end
		if math.floor((i / sharp) + 0.5) == 1 then
			tab = tab .. "sharp "
		elseif math.floor((i / sharp) + 0.5) == 2 then
			tab = tab .. "doublesharp "
		end
		tab = tab .. "\n"
	end
	tab = tab .. "|-\n!Flat symbol\n"
	for i = 1, sharp * 2 + 1 do
		tab = tab .. "|"
		if ((i - (sharp * floor(i / sharp))) / sharp) > math.floor(((i - (sharp * floor(i / sharp))) / sharp) + 0.5) then
			if (i - (sharp * floor(i / sharp))) % 5 == 4 then
				tab = tab .. "up quid "
			else
				for j = 1, (i - (sharp * floor(i / sharp))) % 5 do
					tab = tab .. "down "
				end
			end
			for j = 1, floor((i - (sharp * floor(i / sharp))) / 5) do
				tab = tab .. "quid "
			end
		else
			if ((sharp * ceil(i / sharp)) - i) % 5 == 1 then
				tab = tab .. "down quip "
			else
				for j = 1, ((sharp * ceil(i / sharp)) - i) % 5 do
					tab = tab .. "down "
				end
			end
			for j = 1, floor(((sharp * ceil(i / sharp)) - i) / 5) do
				tab = tab .. "quip "
			end
		end
		if math.floor((i / sharp) + 0.5) == 1 then
			tab = tab .. "flat "
		elseif math.floor((i / sharp) + 0.5) == 2 then
			tab = tab .. "doubleflat "
		end
		tab = tab .. "\n"
	end
	tab = tab .. "|}"
	return tab
end

return p