Module:Infobox RT: Difference between revisions
No edit summary |
added "arx" |
||
(6 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
local infobox = require("Module:Infobox") | local infobox = require("Module:Infobox") | ||
function p.infobox_RT(frame) | |||
-- no real math functionality... yet | |||
local name = frame.args["tempname"] | |||
local subgroup = frame.args["subgroup"] | |||
local basis = frame.args["commas"] | |||
local edo_first = frame.args["edo_first"] | |||
local edo1 = tonumber(edo_first) | |||
local edo_second = frame.args["edo_second"] | |||
local edo2 = tonumber(edo_second) | |||
local tuning = frame.args["tuning"] | |||
local genfrac = frame.args["genfrac"] | |||
local method = frame.args["method"] | |||
local mapping = frame.args["mapping"] | |||
local mos = frame.args["mosses"] | |||
local ploidacot = frame.args["ploidacot"] | |||
local pergen = frame.args["pergen"] | |||
local limit1 = frame.args["lim1"] | |||
local comp1 = frame.args["comp1"] | |||
local acc1 = frame.args["acc1"] | |||
local limit2 = frame.args["lim2"] | |||
local comp2 = frame.args["comp2"] | |||
local acc2 = frame.args["acc2"] | |||
local data = {} | |||
-- processed mapping | |||
local map = {} | |||
local lowermap = {} | |||
table.insert(data, { | |||
"Subgroups", | |||
subgroup | |||
}) | |||
table.insert(data, { | |||
"Comma basis", | |||
basis | |||
}) | |||
table.insert(data, { | |||
"Reduced mapping", | |||
"<" .. mapping .. "]" | |||
}) | |||
-- autocalculating ploidacot | |||
for num in mapping:gmatch("(%d+); ") do | |||
table.insert(map, num) | |||
end | |||
local ploid = map[1] | |||
for num in mapping:gmatch("(%d+) ") do | |||
table.insert(lowermap, num) | |||
end | |||
local equave = string.char(string.byte(subgroup, 1)) | |||
local equave_letter | |||
local cot = tonumber(lowermap[1]) | |||
local referent = string.char(string.byte(subgroup, 3)) | |||
local suffix = "cleft" | |||
if tonumber(equave) == 3 then | |||
equave_letter = "t" | |||
if tonumber(string.char(string.byte(subgroup, 3))) == 5 then | |||
if tonumber(string.char(string.byte(subgroup, 5))) == 7 then | |||
cot = tonumber(lowermap[2]) | |||
suffix = "gem" | |||
else | |||
suffix = "arx" | |||
end | |||
end | |||
if referent == "7" then | |||
suffix = "gem" | |||
elseif tonumber(referent) == 2 then -- edf | |||
equave_letter = "f" | |||
equave = "3/2" | |||
referent = string.char(string.byte(subgroup, 5)) | |||
end | |||
elseif tonumber(equave) == 2 then | |||
equave_letter = "o" | |||
if tonumber(string.char(string.byte(subgroup, 3))) == 3 then | |||
suffix = "cot" | |||
elseif tonumber(string.char(string.byte(subgroup, 3))) == 5 then | |||
suffix = "seph" | |||
end | |||
else | |||
equave_letter = equave | |||
end | |||
if suffix == "cleft" then | |||
suffix = referent .. suffix | |||
end | |||
local ploidnum = math.log(tonumber(equave))*(1200/math.log(2))/tonumber(ploid) | |||
local tuningnum = tonumber(tuning) | |||
if cot < 0 then | |||
tuningnum = math.log(tonumber(equave))*(1200/math.log(2)) - tuningnum | |||
cot = math.abs(cot) | |||
end | |||
local shear = math.floor(tuningnum*cot/ploidnum) | |||
shear = math.floor(cot*(shear/cot - math.floor(shear/cot))) | |||
if cot > 2 then | |||
if shear == cot-1 then | |||
shear = -1 | |||
end | |||
end | |||
suffix = p.num2greeklet(tostring(shear)) .. p.num2greek(tostring(cot), "cot") .. suffix | |||
if ploid ~= "1" then | |||
suffix = p.num2greek(ploid,"ploid") .. "ploid " .. suffix | |||
end | |||
if ploidacot == "0" then | |||
ploidacot = suffix | |||
end | |||
-- edo join | |||
table.insert(data, { | |||
"Edo join", | |||
"[[" .. edo_first .. "ed" .. equave_letter .. "|" .. edo_first .. "]] & [[" .. edo_second .. "ed" .. equave_letter .. "|" .. edo_second .. "]]" | |||
}) | |||
table.insert(data, { | |||
"Generator ([[" .. method .. "]])", | |||
"~" .. genfrac .. " = " .. tuning .. "c" | |||
}) | |||
if mos ~= "0" then | |||
table.insert(data, { | |||
"MOS scales", | |||
mos | |||
}) | |||
end | |||
table.insert(data, { | |||
"Ploidacot", | |||
ploidacot | |||
}) | |||
if pergen ~= "0" then | |||
table.insert(data, { | |||
"Pergen", | |||
pergen | |||
}) | |||
end | |||
-- error and stuff | |||
local oddlim | |||
if equave_letter == "o" then | |||
oddlim = "-[[odd limit]]) " | |||
elseif equave_letter == "t" then | |||
oddlim = "-[[throdd limit]]) " | |||
else | |||
oddlim = "-[[integer limit]]) " | |||
end | |||
local string1 = "(" .. limit1 .. oddlim .. acc1 .. "c" | |||
local string2 = "(" .. limit1 .. oddlim .. comp1 .. " notes" | |||
if limit2 ~= "0" then | |||
string1 = string1 .. "; <br> (" .. limit2 .. oddlim .. acc2 .. "c" | |||
string2 = string2 .. "; <br> (" .. limit2 .. oddlim .. comp2 .. " notes" | |||
end | |||
table.insert(data, { | |||
"Minmax error", | |||
string1 | |||
}) | |||
table.insert(data, { | |||
"Target scale size", | |||
string2 | |||
}) | |||
local result = infobox.build( | |||
name, | |||
data | |||
) | |||
return result | |||
end | |||
function p.digit2greek(number, purpose) | function p.digit2greek(number, purpose) | ||
Line 40: | Line 222: | ||
end | end | ||
elseif number == "4" then | elseif number == "4" then | ||
greek = "tetra" | if purpose == "decade" then | ||
greek = "tessera" | |||
else | |||
greek = "tetra" | |||
end | |||
elseif number == "5" then | elseif number == "5" then | ||
greek = "penta" | if purpose == "decade" then | ||
greek = "pente" | |||
else | |||
greek = "penta" | |||
end | |||
elseif number == "6" then | elseif number == "6" then | ||
greek = "hexa" | if purpose == "decade" then | ||
greek = "hexe" | |||
else | |||
greek = "hexa" | |||
end | |||
elseif number == "7" then | elseif number == "7" then | ||
greek = "hepta" | if purpose == "decade" then | ||
greek = "hebdome" | |||
else | |||
greek = "hepta" | |||
end | |||
elseif number == "8" then | elseif number == "8" then | ||
greek = "octa" | if purpose == "decade" then | ||
greek = "ogdoe" | |||
elseif purpose == "unit" then | |||
greek = "octo" | |||
else | |||
greek = "octa" | |||
end | |||
elseif number == "9" then | elseif number == "9" then | ||
greek = "ennea" | if purpose == "decade" then | ||
greek = "enene" | |||
else | |||
greek = "ennea" | |||
end | |||
end | end | ||
if purpose == "decade" then | if purpose == "decade" then | ||
Line 155: | Line 363: | ||
end | end | ||
return greek | return greek | ||
end | end | ||
return p | return p |