Module:Ups and downs notation: Difference between revisions
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
| Line 35: | Line 35: | ||
function p.get_note_names_table(et) | function p.get_note_names_table(et) | ||
local note_names = {} | local note_names = {} | ||
for i = 0,et.size-1 do | |||
note_names[i] = {} | note_names[i] = {} | ||
i = i + 1 | i = i + 1 | ||
| Line 67: | Line 66: | ||
-- Add sharp/up notes | -- Add sharp/up notes | ||
local last_major_note = nil | |||
local last_major_note = | for i = 0,et.size-1 do | ||
if table_contains(major_note_idx, i) then | if table_contains(major_note_idx, i) then | ||
last_major_note = i | last_major_note = i | ||
| Line 80: | Line 78: | ||
end | end | ||
local names = note_names[last_major_note] | local names = note_names[last_major_note] | ||
for name in names do | |||
name = string.rep("^", num_ups) .. name .. string.rep("#", num_sharps) | |||
end | end | ||
note_names[i] = name | note_names[i] = name | ||
end | end | ||
end | end | ||
-- Add flat/down notes | -- Add flat/down notes | ||
i = et.size - 1 | for i = et.size-1,0,-1 do | ||
if table_contains(major_note_idx, i) then | if table_contains(major_note_idx, i) then | ||
last_major_note = i | last_major_note = i | ||
else | |||
local num_flats = math.floor((last_major_note - i) / chroma) | local num_flats = math.floor((last_major_note - i) / chroma) | ||
local num_downs = (last_major_note - i) % chroma | local num_downs = (last_major_note - i) % chroma | ||
if chroma == 0 then | if chroma == 0 then | ||
num_flats = 0 | num_flats = 0 | ||
num_downs = (last_major_note - i) | num_downs = (last_major_note - i) | ||
end | end | ||
for name in note_names[last_major_note] do | |||
name = string.rep("v", num_downs) .. name .. string.rep("b", num_flats) | |||
table.insert(note_names[i], name) | |||
name = name .. "b" | |||
end | end | ||
end | end | ||
end | end | ||
return note_names | return note_names | ||