alda-lang / alda

A music programming language for musicians. :notes:
https://alda.io
Eclipse Public License 2.0
5.62k stars 289 forks source link

Add check for extra rest duration #462

Open kylewilk567 opened 1 year ago

kylewilk567 commented 1 year ago

Patch to fix issue #421 . Checks the ending duration of what is sent to the client matches the PartOffset in the Score object. If there is a mismatch (as in the case with a trailing rest), extra duration is appended to the last note.

daveyarwood commented 1 year ago

Thanks for the PR, Kyle! It looks good overall, apart from the thing I mentioned above.

I'll do some manual testing soon when I have time, and merge it if everything looks and sounds good.

daveyarwood commented 1 year ago

This doesn't appear to fix the issue in #421, unfortunately :(

Here's what I did to test:

client/bin/run repl \
  --client \
  --port 12345 \
  --message '{"op": "eval-and-play", "code": "percussion: o2 (tempo 240) c4 r4 c4 r4 | c4 r4 c4 r4 | c4 r4 c4 r4 | c4 r4 d4 r4"}'

The "hiccup" is still there where the final rest is skipped.

kylewilk567 commented 1 year ago

I tested the code using the following commands in Windows Powershell and it works: image

The r4 that occurs at the end of the first line is correctly handled. I wasn't able to replicate it using the procedure above since my Alda executable in my PCs PATH is the old version. Do you have any suggestions as to why our testing may have given different results?

daveyarwood commented 1 year ago

@kylewilk567 Sorry for the late reply - I've been on vacation the last couple weeks.

This is interesting! I tried it the way you described, and I also heard the last rest being handled correctly. But I tried it again the way I described (running a REPL server in another terminal and using the CLI to send it messages), and the rest is still getting left out when I do it that way.

I wonder if there is some important difference in the way the messages are being sent to the REPL server when you do it via the CLI vs. doing it interactively in a REPL client session?