Module:Ups and downs notation: Difference between revisions
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
-- WIP | -- WIP | ||
local | local et = require('Module:ET') | ||
local rat = require('Module:Rational') | local rat = require('Module:Rational') | ||
local p = {} | local p = {} | ||
| Line 23: | Line 23: | ||
-- } | -- } | ||
function p.get_note_names( | function p.get_note_names(tuning) | ||
local note_names = {} | local note_names = {} | ||
local i = 0 | local i = 0 | ||
while i < tuning.size do | |||
while i < | |||
note_names[i] = {} | note_names[i] = {} | ||
end | end | ||
local fifth = | local fifth = et.approximate(tuning, rat.new(3, 2)) | ||
local fourth = | local fourth = et.approximate(tuning, rat.new(4, 3)) | ||
local chroma = (fifth * 7) % et.size | local chroma = (fifth * 7) % et.size | ||
-- Add major scale notes | -- Add major scale notes | ||
table.insert(note_names[0], "C") | table.insert(note_names[0], "C") | ||
table.insert(note_names[(fifth * 2) % | table.insert(note_names[(fifth * 2) % tuning.size], "D") | ||
table.insert(note_names[(fifth * 4) % | table.insert(note_names[(fifth * 4) % tuning.size], "E") | ||
table.insert(note_names[fourth], "F") | table.insert(note_names[fourth], "F") | ||
table.insert(note_names[fifth], "G") | table.insert(note_names[fifth], "G") | ||
table.insert(note_names[(fifth * 3) % | table.insert(note_names[(fifth * 3) % tuning.size], "A") | ||
table.insert(note_names[(fifth * 5) % | table.insert(note_names[(fifth * 5) % tuning.size], "B") | ||
table.insert(note_names[et.size], "C") | table.insert(note_names[et.size], "C") | ||
i = 0 | i = 0 | ||
local last_major_note = 0 | local last_major_note = 0 | ||
while i < | while i < tuning.size do | ||
if #(note_names[i]) == 0 then | if #(note_names[i]) == 0 then | ||
local num_sharps = math.floor((i - last_major_note) / chroma) | local num_sharps = math.floor((i - last_major_note) / chroma) | ||