> On Apr 6, 2016, at 11:26 AM, Jordan Johnson <j...@fellowhuman.com> wrote: > > Hey, so I’m now looking at how to set up background music in rsound with the > ability to switch tracks. Below is the suggestion from John Clements that > seems right: >>> I’m guessing you’re looking for an imperative API that looks something like >>> this: >>> >>> (start-playing! stream sound at-time #:fade-in time-duration) => token >>> (stop-playing! stream token at-time #:fade-out time-duration) > > AFAICT this isn’t already in existence in the rsound library. My impression > is that we will need to build this on top of signals and networks — but I > want to check that, before we pour the time into doing it. > > I’m thinking signals & networks because we tried to build it using pstreams, > and ran into a snag when trying to stop playback and switch to a new track: > > ;; Given a pstream bgmusic and rsounds bgsong1, bgsong2, the following > Interactions > ;; occur: > > (pstream-play bgmusic bgsong1) > "sound is queued" > > (stop) > > (pstream-play bgmusic bgsong2) > "sound is queued" ;; BUT NO SOUND PLAYS. > > > ;; - end interactions - > > So, am I correct in thinking that pstreams aren’t sufficient for what I’m > attempting? Is there another way to stop playback, other than calling (stop)?
You are correct. with one tiny caveat. 1) The “stop” procedure is a giant end-of-the-world hammer; I wouldn’t expect it to be useful while a program is running. 2) I hesitate to suggest this, but there is a “pstream-set-volume!” function that can silence a pstream. (that was the caveat.) 3) You are also correct in your supposition that the interface I proposed is not implemented. It looks like it could be done quickly, meaning probably on the order of 10-20 hours of work for me. The relevant code to look at here would probably be https://github.com/jbclements/RSound/blob/master/rsound/sequencer.rkt In fact, the pstream library (in stream-play.rkt) is just a thin skin over the sequencer code. Adding the stop-playing! call would probably involve adding some king of message queue to the sequencer to receive fade-out messages, and updating the ‘entry’ structure to contain information about sounds that are currently fading in or out. John > > Thanks, > Jordan > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.