Module:Ups and downs notation: Difference between revisions
debugging... |
should work... |
||
| Line 67: | Line 67: | ||
last_diatonic_note = i | last_diatonic_note = i | ||
else | else | ||
local num_double_sharps = math.floor((i - last_diatonic_note) / (2 * chroma)) | local num_double_sharps = 0 -- was math.floor((i - last_diatonic_note) / (2 * chroma)) | ||
local num_sharps = | local num_sharps = round((i - last_diatonic_note) / chroma) | ||
if num_sharps > 1 then | |||
num_double_sharps = math.floor(num_sharps / 2) | |||
num_sharps = num_sharps % 2 | |||
end | |||
local num_ups = (i - last_diatonic_note) % chroma | local num_ups = (i - last_diatonic_note) % chroma | ||
local num_downs = 0 | |||
if chroma == 0 then | if chroma == 0 then | ||
num_double_sharps = 0 | num_double_sharps = 0 | ||
num_sharps = 0 | num_sharps = 0 | ||
num_ups = (i - last_diatonic_note) | num_ups = (i - last_diatonic_note) | ||
end | |||
if num_ups > chroma / 2 then | |||
num_downs = chroma - num_ups | |||
num_ups = 0 | |||
end | end | ||
local last_diatonic_names = note_names[last_diatonic_note] | local last_diatonic_names = note_names[last_diatonic_note] | ||
for j = 1, #last_diatonic_names do | for j = 1, #last_diatonic_names do | ||
if num_ups >= 3 then | if num_downs >= 3 then | ||
table.insert( | |||
note_names[i], | |||
"v<sup>" .. num_downs .. "</sup>" .. last_diatonic_names[j] | |||
.. string.rep("♯", num_sharps) .. string.rep("𝄪", num_double_sharps) ) | |||
elseif num_downs > 0 then | |||
table.insert( | |||
note_names[i], | |||
string.rep("v", num_downs) .. last_diatonic_names[j] | |||
.. string.rep("♯", num_sharps) .. string.rep("𝄪", num_double_sharps) | |||
) | |||
elseif num_ups >= 3 then | |||
table.insert( | table.insert( | ||
note_names[i], | note_names[i], | ||