alda-lang / alda-server-clj

A Clojure implementation of an Alda server
Other
2 stars 2 forks source link

Support history option when playing code #6

Closed daveyarwood closed 7 years ago

daveyarwood commented 7 years ago

Building upon #4.

jgkamat commented 7 years ago

@daveyarwood this does fix most of the cases I talked about in #4, but this case still throws an error:

play --history 'c d e e f piano: c d e' --code 'piano: c d e'
c d e e f 
^
Expected one of:
"⚙"
#"[a-zA-Z]{2}[\w_]*"

Ideally I wouldn't like to deal with this case in the repl, but I'm fine with adding a check if we need to.

EDIT: Interestingly, these cases seem to work: play --history 'c d e' --code 'c d e' play --history 'c d e' --code 'piano: c d e'

daveyarwood commented 7 years ago

Ah, I see what's going on -- c d e is being considered valid because it parses within the context of note events in a part.

However, c d e e f piano: c d e is not being considered valid because it isn't events from a single part, nor is it a single part, nor is it a valid score.

I think the right thing to do here is to make it so that c d e e f piano: c d e is considered valid Alda code by the parser (after all, it is syntactically valid: 5 notes, a piano declaration, 3 notes), but then throw an error at score evaluation time when it tries to add the first c note to a new score with no instruments declared.

I am working on replacing the parser code, and I'm confident I can make it work like the above. I took a look at the existing code to see if I could maybe hack in the functionality we want, but unfortunately, the code we have now (generating parsers from BNF grammars) is fragile and I'm hesitant to mess with it.

jgkamat commented 7 years ago

I think I might have found another small bug in these changes, from and to arguments don't seem to work. eg: play --code 'piano: c d e' -F 0:10 seems to play notes, when it shouldn't.

Not extremely important right now (I think), but hopefully that can be fixed when the parser is redone!

daveyarwood commented 7 years ago

Hmm... I'm not able to reproduce that issue. When I run alda play --code 'piano: c d e' -F 0:10, I hear nothing, which is correct. When I change it to -F 0:01, I hear just the last note, which also seems correct.

I wonder if the issue is your local build? There are updated (but not yet released) versions of alda/client-java, alda/server-clj and alda/sound-engine-clj.

EDIT: Whoops! I actually can reproduce the issue -- I was using the wrong Alda server.

daveyarwood commented 7 years ago

I see what's going on -- I think it's a bug related to what I did here in sound-engine-clj. I'm working on a fix.

daveyarwood commented 7 years ago

Fixed in sound-engine-clj 0.1.2 / server-clj 0.1.4.