alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

alda stop hangs on sustained notes #44

Closed elydpg closed 7 years ago

elydpg commented 7 years ago

this happens on both my mac and windows machine. the alda stop command sometimes hangs on the last note played and holds it forever without stopping. Haven't been able to accurately replicate it, but it seems to happen more with instruments which don't fade their sound over time.

jgkamat commented 7 years ago

I think I've had this happen once or twice. This is definitely going to be a hard one to catch unless we can find a way to reliably reproduce it.... 😢

EDIT: if it's any help, I have a feeling this is more likely to happen when the server is just coming up, but that might be a hunch.

daveyarwood commented 7 years ago

I've noticed some inconsistent behavior with alda stop intermittently doing nothing. I did notice that when that happened, running alda stop again would stop the playback. I think there may be some timing issues that we need to address.

As @jgkamat noted, it would be good if we can manage to reliably reproduce the problem. At this point, I'm not 100% sure where the problem is / how to fix it.

elydpg commented 7 years ago

This score seems to be able to reproduce it when trying to stop during the parts with a sustained instrument (violin or trumpet in this case). Haven't been able to find a smaller snippet of code which triggers it.

(Also, mind checking slack? Having some soundfont issues which probably don't merit a github issue)

jgkamat commented 7 years ago

Wow, that's such a nice song! :smile: (I wish I could actually make music :stuck_out_tongue:)

As for that file, I worked on cutting it down, and I can reproduce the same behavior with this file:

test_sustain.alda.txt

It seems that you need to have multiple instruments initialized (but not necessarily playing) in order to trigger this, which is why I had such a hard time replicating this when testing the repl :)

daveyarwood commented 7 years ago

I'm able to reproduce the issue. Weird!

I'm going to try a couple things and see if I can find a more foolproof way to stop the sound. Right now we are calling [allSoundOff](https://docs.oracle.com/javase/7/docs/api/javax/sound/midi/MidiChannel.html#allSoundOff()) on every channel. I see there is also an [allNotesOff](https://docs.oracle.com/javase/7/docs/api/javax/sound/midi/MidiChannel.html#allNotesOff()), so I'll try that. Maybe we should do both 😄

daveyarwood commented 7 years ago

Fixed in alda 1.0.0-rc61.