jbclements / RSound

A cross-platform sound library for DrRacket
http://www.brinckerhoff.org/clements
Other
45 stars 11 forks source link

Request to implement pstream-stop and pstream-pause #28

Open benoid opened 7 years ago

benoid commented 7 years ago

Currently, the stop procedure stops all sounds being played by RSound. Would it be possible to implement a stop procedure that could stop an individual pstream while allowing the others to continue playing?

Perhaps a pstream-stop procedure could stop and clear the pstream, and a pstream-pause procedure could stop the pstream without clearing it?

I'm not sure I am yet familiar enough with how RSound interacts with portaudio to implement this myself, but I'm willing to have a go at it, provided you can point me in the right direction on where in the code base to look.

Thanks!

jbclements commented 7 years ago

That's not a super-functional interface, but yes, it's probably possible. I believe you want to take a look at sequencer.rkt, which (IIRC) is where all of the heap-queueing stuff happens. Stopping should be not-too-difficult. Pausing is going to be more difficult, because the queue times of all the current elements of the heap will have to be increased in order to re-start the stream.

benoid commented 7 years ago

Thanks!

benoid commented 7 years ago

I just implemented a procedure called pstream-clear, which clears all queued rsounds from a given pstream. It doesn't abruptly stop any rsounds currently playing, but sound will stop once the current rsound is over.

I also added tests for the sequencer level procedure clear-all-sounds! which deals directly with the heap. The test suite passes after the addition of the new functionality.

I submitted a pull request: https://github.com/jbclements/RSound/pull/29

benoid commented 7 years ago

I'm not going to close this actually. I think there is still a need for a method to stop a pstream.