jbclements / RSound

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

Question: mixing to avoid clicks #39

Open ericclack opened 5 years ago

ericclack commented 5 years ago

I'm trying to make a simple drum machine in Racket for educational purposes -- to learn about drum patterns and to learn more Racket. I'm running into problems with clicks and crackles.

I've got a DSL that I'm sort of happy with, and I'm using rsound to play the samples as appropriate: e.g. https://github.com/ericclack/racket-beats/blob/rsound/heart1.rkt https://github.com/ericclack/racket-beats/blob/rsound/synco1.rkt

If I increase the bpm in the heart1 example to 300+ then there are quite a few clicks. I would guess that this is because the stream I'm playing on hasn't finished the playing the previous sample before I ask it to play the next one.

I think the right way to use rsound and portaudio is for my code to do the mixing before sequencing the samples for playback. But looking at how the DSL is evolving I won't ever know which samples might overlap.

So I'm keen to play with the rsound code to see if I can fix this. I'm thinking I could add some mixing capability to the sequencer code, or quickly fade out any currently playing sample.

I'd welcome any advice or pointers... -Eric.