alda-lang / alda

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

Alda REPL "skips" rests at the end of a line #421

Open daveyarwood opened 2 years ago

daveyarwood commented 2 years ago

🐞 Bug report 🐞

Description

@litan on Alda Slack observed that if you run the following command twice in succession:

alda repl \
  --client \
  --port 43009 \
  --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"}'

It appends the two together as expected, however, the r4 at the end gets stripped off, so the c4 at the beginning of the second command ends up happening a quarter note too soon.

I was also able to reproduce this in an interactive Alda REPL session.

Steps to Reproduce

  1. Run alda repl to start a REPL session.
  2. Enter percussion: o2 (tempo 240) c4 r4 c4 r4 | c4 r4 c4 r4 | c4 r4 c4 r4 | c4 r4 d4 r4 and press Enter.
  3. Before that line finishes playing, press Up arrow, Enter to enter the same line again.

Expected Behavior

The notes you hear are all spaced apart by quarter note rests.

Actual Behavior

It sounds like the r4 quarter note rest at the end of the first line is omitted, and there is a "hiccup" where the second line starts a quarter note too early.

Environment

Operating system and version: Ubuntu 20.04

Alda version: 2.2.3