smallpond

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/smallpond
Log | Files | Refs | README | LICENSE

commit 10d05bedc5986d603e2be7a7244dbc4063e8a25a
parent 13c8b18b02c7ff99a66f656f821b6048c961ca95
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Tue,  4 Oct 2022 23:21:24 -0500

change octave as part of note expression

Diffstat:
Msmallpond.lua | 22+++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/smallpond.lua b/smallpond.lua @@ -94,7 +94,7 @@ local commands = { voice = function (text, start) local parsenote = function(text, start) -- TODO: should we be more strict about accidentals and stem orientations on rests? - local s, e, note, acc, flags, count = string.find(text, "^([abcdefgs])([fns]?)([v^]?)(%d*)", start) + local s, e, note, acc, flags, shift, count = string.find(text, "^([abcdefgs])([fns]?)([v^]?)([,']*)(%d*)", start) if note then -- make sure that count is a power of 2 if #count ~= 0 then @@ -111,6 +111,9 @@ local commands = { elseif string.find(flags, "^", 1, true) then out.stemdir = -1 end + local _, down = string.gsub(shift, ',', '') + local _, up = string.gsub(shift, "'", '') + out.shift = up - down return start + e - s + 1, out end @@ -142,19 +145,6 @@ local commands = { goto start end - local s, e = string.find(text, "^'", i) - if s then - i = i + e - s + 1 - table.insert(voice, {command="changeoctave", count=-(e - s + 1)}) - goto start - end - - local s, e = string.find(text, "^,", i) - if s then - i = i + e - s + 1 - table.insert(voice, {command="changeoctave", count=e - s + 1}) - goto start - end local s, e, count = string.find(text, "^%b<>(%d+)", i) if s then i = i + 1 @@ -246,6 +236,7 @@ abstract_dispatch = { -- TODO: should we be emitting a beam here? end for _, note in ipairs(data.notes) do + octave = octave - note.shift table.insert(heads, {acc=note.acc, stemdir=note.stemdir, y=clef.place(note.note, octave)}) end local note = {kind="notecolumn", beamed=beamed, beamcount=beamcount, stemlen=3.5, length=data.count, time=time, heads=heads} @@ -272,9 +263,6 @@ abstract_dispatch = { table.insert(staff1[curname], {kind="barline"}) lastnote = nil end, - changeoctave = function(data) - octave = octave + data.count - end, srest = function(data) table.insert(staff1[curname], {kind='srest', length=data.count, time=time}) time = time + 1 / data.count