Module:Ups and downs notation: Difference between revisions

CompactStar (talk | contribs)
No edit summary
CompactStar (talk | contribs)
No edit summary
Line 4: Line 4:
local u = require("Module:Utils")
local u = require("Module:Utils")
local p = {}
local p = {}
local function table_contains(tbl, x)
    found = false
    for _, v in pairs(tbl) do
        if v == x then
            found = true
        end
    end
    return found
end


-- Returns a nested table of note names
-- Returns a nested table of note names
Line 23: Line 35:
-- }
-- }


local function table_contains(tbl, x)
function p.get_note_names_table(et)
    found = false
    for _, v in pairs(tbl) do
        if v == x then
            found = true
        end
    end
    return found
end
 
 
function p.get_note_names(tuning)
local et = ET.parse("12edo")
local note_names = {}
local note_names = {}
local i = 0
local i = 0
Line 42: Line 42:
end
end
local fifth = u.round(math.log(3/2)/math.log(2) * tuning.size)
local fifth = u.round(math.log(3/2)/math.log(2) * et.size)
local fourth = u.round(math.log(4/3)/math.log(2) * tuning.size)
local fourth = u.round(math.log(4/3)/math.log(2) * et.size)
local chroma = (fifth * 7) % ET.size
local chroma = (fifth * 7) % et.size
local major_note_idx = {
local major_note_idx = {
Line 119: Line 119:
end
end


function p.get_specific_note_name(tuning, steps)
function p.ups_and_downs_note_name(frame)
tbl = p.get_note_names(tuning)[steps]
local et = et.parse(frame.args[0])
result = ''
local steps = tonumber(frame.args[1])
i = 0
local tbl = p.get_note_names_table(tuning)[steps]
local result = ''
local i = 0
while i < #tbl do
while i < #tbl do
result = result + tbl[i] + ','
result = result + tbl[i] + ','