Implementing an anti-click crossfade over very short sample times?

Hello,

I’m developing a simple module which is a looping recorder. It’s working, but I’d like to implement an anti-click / crossfade option, so that any new samples recorded into the loop buffer are faded in and out over 5 milliseconds or so.

I can write custom code to do that, but just would like to ask if any of the more cleverer people here knows of functions in the VCV SDK which can help with that? :slight_smile:

Many thanks, Alan.

EDIT: I should point out my current thinking, instead of just asking! :slight_smile: So, when a new recording is started, a rack::dsp::PulseGenerator is triggered, and over the time the PulseGenerator is “high”, its remaining value is used to set the linear / curved crossfade. Same when the recording is stopped. That sound like a good approach, maybe?

I believe the SDK includes a dsp::slewLimiter which might be what you are looking for. Feed your crossfade ratio through that to limit the rate of change.

1 Like

Thanks! :slight_smile:

There’s a crossfade function too, but I haven’t looked into the functionality.

If you want an example of something similar, I wrote code that did basically what you are describing in my Repeat3hr module. Upon detecting a change in the delay time, it fades the volume going into the feedback buffer to zero over the amount of samples remaining until the delayline resets, then fades it back in after the reset, which eliminates almost all discontinuities in the waveform.

1 Like

Thanks! I really should look through the VCV code more. :slight_smile:

I know that this is a very old post, but I’m doing the same thing and wanted to mention that I initially tried using the built-in crossfade function for crossfading between audio, but it didn’t do what I expected and I ended up writing my own.

1 Like