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: | ||
-- } | -- } | ||
function p.get_note_names_table(et) | |||
function p. | |||
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) * | local fifth = u.round(math.log(3/2)/math.log(2) * et.size) | ||
local fourth = u.round(math.log(4/3)/math.log(2) * | local fourth = u.round(math.log(4/3)/math.log(2) * et.size) | ||
local chroma = (fifth * 7) % | local chroma = (fifth * 7) % et.size | ||
local major_note_idx = { | local major_note_idx = { | ||
| Line 119: | Line 119: | ||
end | end | ||
function p. | function p.ups_and_downs_note_name(frame) | ||
tbl = p. | 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] + ',' | ||