Module:ET: Difference between revisions

ArrowHead294 (talk | contribs)
Replace rational approximations with exact values. Is this working?
These all looked too dumb tbh
 
(18 intermediate revisions by 2 users not shown)
Line 2: Line 2:
local seq = require("Module:Sequence")
local seq = require("Module:Sequence")
local p = {}
local p = {}
-- TODO: we should not represent the equave as a rational number at all


local common_suffix = {
local common_suffix = {
Line 17: Line 15:
["o"] = 2,
["o"] = 2,
["t"] = 3,
["t"] = 3,
-- TODO: these should not be here
["ϕ"] = (1 + math.sqrt(5)) / 2,
["ϕ"] = (1 + math.sqrt(5)) / 2,
["n"] = math.exp(1),
["n"] = math.exp(1),
Line 46: Line 42:
-- parse a ET structure
-- parse a ET structure
function p.parse(unparsed)
function p.parse(unparsed)
local size, suffix, equave = unparsed:match("^(%d+)([Ee][Dd](.+))$")
local size, suffix, equave = unparsed:match("^(%d+%.*%d*)([Ee][Dd](.+))$")
-- local size, suffix, equave = unparsed:match("^(%d+%.*%d*)([Cc]?[Ee][Dd]?[Tt]?(.*))$")
if equave == nil then
if equave == nil then
return nil
return nil
Line 93: Line 90:
steps = steps or 1
steps = steps or 1
return 1200 * steps / et.size * math.log(rat.as_float(et.equave)) / math.log(2)
return 1200 * steps / et.size * math.log(rat.as_float(et.equave)) / math.log(2)
end
-- convert steps to hekts
function p.hekts(et, steps)
if et.size == 0 then
return 0
end
steps = steps or 1
return 1300 * steps / et.size * math.log(rat.as_float(et.equave)) / math.log(3)
end
end


Line 144: Line 150:
local zeta_integral = seq.contains(seq.zeta_integral, et.size)
local zeta_integral = seq.contains(seq.zeta_integral, et.size)
local zeta_gap = seq.contains(seq.zeta_gap, et.size)
local zeta_gap = seq.contains(seq.zeta_gap, et.size)
local z = "The Riemann zeta function and tuning#Zeta EDO lists"


local markers = {}
local markers = {}
if zeta_peak then
if zeta_peak then
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak]]")
table.insert(markers, string.format("[[%s|Zeta peak]]", z))
elseif zeta_peak == nil then
elseif zeta_peak == nil then
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak?]]")
table.insert(markers, string.format("[[%s|Zeta peak?]]", z))
end
end


if zeta_peak_integer then
if zeta_peak_integer then
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer]]")
table.insert(markers, string.format("[[%s|Zeta peak integer]]", z))
elseif zeta_peak_integer == nil then
elseif zeta_peak_integer == nil then
table.insert(markers, "[[The Riemann zeta function and tuning #Peak EDOs|zeta peak integer?]]")
table.insert(markers, string.format("[[%s|Zeta peak integer?]]", z))
end
end


if zeta_integral then
if zeta_integral then
table.insert(markers, "[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral]]")
table.insert(markers, string.format("[[%s|Zeta integral]]", z))
elseif zeta_integral == nil then
elseif zeta_integral == nil then
table.insert(markers, "[[The Riemann zeta function and tuning #Integral of Zeta EDOs|zeta integral?]]")
table.insert(markers, string.format("[[%s|Zeta integral?]]", z))
end
end


if zeta_gap then
if zeta_gap then
table.insert(markers, "[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap]]")
table.insert(markers, string.format("[[%s|Zeta gap]]", z))
elseif zeta_gap == nil then
elseif zeta_gap == nil then
table.insert(markers, "[[The Riemann zeta function and tuning #Zeta Gap EDOs|zeta gap?]]")
table.insert(markers, string.format("[[%s|Zeta gap?]]", z))
end
end


return table.concat(markers, "<br>")
return table.concat(markers, "<br />")
end
end


return p
return p