Module:Ups and downs sharpness: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Tristanbay (talk | contribs)
begin working on module; not finished yet
 
Tristanbay (talk | contribs)
Continued work on module, still not finished
Line 17: Line 17:
return math.max((4 * math.floor((edo * math.log(3) / math.log(2)) + 0.5)) - math.floor((edo * math.log(5) / math.log(2)) + 0.5) - (4 * edo), 1)
return math.max((4 * math.floor((edo * math.log(3) / math.log(2)) + 0.5)) - math.floor((edo * math.log(5) / math.log(2)) + 0.5) - (4 * edo), 1)
end
end
end
-- generate table
local function make_table(sharp, comma)
local thead = "{| class=\"wikitable center-all\"\n"
local tlabel = "|-\n! Step offset\n{{!}}'''0'''"
local tsharp = "|-\n! Sharp symbol\n| rowspan=\"2\" |  [[File:Heji18.svg|15px]]"
local tflat = "|-\n! Flat symbol"
for i=1, sharp*2 do
if i % sharp == 0 then
table.insert(tlabel, "'''" .. i .. "'''")
else
table.insert(tlabel, "" .. i)
end
end
return thead .. table.concat(tlabel, "\n|") .. "\n|}"
end
end

Revision as of 03:44, 19 September 2025

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 (0)
Line Function Params
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

-- calculate amount of steps for up/down
local function comma_n(edo)
	if edo < 66 then
		return 1
	elseif edo == 129 then
		return 3
	else -- mapping of 81/80
		return math.max((4 * math.floor((edo * math.log(3) / math.log(2)) + 0.5)) - math.floor((edo * math.log(5) / math.log(2)) + 0.5) - (4 * edo), 1)
	end
end

-- generate table
local function make_table(sharp, comma)
	local thead = "{| class=\"wikitable center-all\"\n"
	local tlabel = "|-\n! Step offset\n{{!}}'''0'''"
	local tsharp = "|-\n! Sharp symbol\n| rowspan=\"2\" | &nbsp;[[File:Heji18.svg|15px]]"
	local tflat = "|-\n! Flat symbol"
	
	for i=1, sharp*2 do
		if i % sharp == 0 then
			table.insert(tlabel, "'''" .. i .. "'''")
		else
			table.insert(tlabel, "" .. i)
		end
	end
	return thead .. table.concat(tlabel, "\n|") .. "\n|}"
end