Module:Ups and downs notation: Difference between revisions
CompactStar (talk | contribs) Created page with "local et = require('Module:ET') local rat = require('Module:Rational') local p = {} -- Returns a nested table of note names -- e.g. for 12edo, intended result would be someth..." |
CompactStar (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
-- WIP | |||
local et = require('Module:ET') | local et = require('Module:ET') | ||
local rat = require('Module:Rational') | local rat = require('Module:Rational') | ||
| Line 32: | Line 34: | ||
local fourth = ET.approximate(et, rat.new(4, 3)) | local fourth = ET.approximate(et, rat.new(4, 3)) | ||
local chroma = (fifth * 7) % et.size | local chroma = (fifth * 7) % et.size | ||
table.insert( | |||
table.insert( | -- Add major scale notes | ||
table.insert(note_names[0], "C") | |||
table.insert(note_names[(fifth * 2) % et.size], "D") | |||
table.insert(note_names[(fifth * 4) % et.size], "E") | |||
table.insert(note_names[fourth], "F") | |||
table.insert(note_names[fifth], "G") | |||
table.insert(note_names[(fifth * 3) % et.size], "A") | |||
table.insert(note_names[(fifth * 5) % et.size], "B") | |||
table.insert(note_names[et.size], "C") | |||
i = 0 | i = 0 | ||
local | local last_major_note = 0 | ||
while i < et.size do | while i < et.size do | ||
if note_names[i] == | if #(note_names[i]) == 0 then | ||
local num_sharps = math.floor((i - | local num_sharps = math.floor((i - last_major_note) / chroma) | ||
local num_ups = (i - | local num_ups = (i - last_major_note) % chroma | ||
local name = interval_names[ | local name = interval_names[last_major_note] | ||
local j = 0 | local j = 0 | ||
while j < num_sharps do | while j < num_sharps do | ||
| Line 60: | Line 60: | ||
name = "^" + name | name = "^" + name | ||
end | end | ||
note_names[i] | table.insert(note_names[i], note_names[last_note]) | ||
else | else | ||
last_major_note = i | |||
end | end | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
end | end | ||
return p | return p | ||