easy way to load new sample into buffer~ during playback w/out clicking
i'm trying to load a new sample into a buffer~ while it's playing, and naturally there is some audible clicking when the playback jumps from the old sample to the new. is there some easy way to do this or will i have to use two separate buffers and cross-fade between them and manage all the switching manually?
additionally: i am actually using a polybuffer, but the IDs are already used up in the patch (i.e. buffer.1 is dedicated to a certain part in the patch, buffer.2 to another and so forth...)
working in m4l but i guess this is more of a general question.
Mischmeisterm,
Here is one way to do what you want. I'm sure there are many other ways, as well.
In the patch, I've used a [trigger b b b] object to send three bangs.
The first bang ramps the [groove~] object's output to 0 in 10 ms.
The second bang loads in the new sound file (after a 10 ms delay).
The third bang ramps the [groove~] object's output back up to 1 (also after a 10 ms delay).
Hope this helps,
Mitch
In the example above one could use file read completed bang from buffer
to bring the volume up again, still with gap, but fade in would not take place too early
if sample needs longer than 10 ms to load.
If you want no gap sample replace, really smooth can be only to crossfade between old and new sample
I would use a temporary buffer to cross the playback
while buffer is replacing the sample
It all depends when loading takes place, how big files are
etc
Example:
Buffer A is playing in a loop
You want to replace the sample inside...
copy buffer A to TEMP buffer, (send message duplicate A to TEMP buffer)
crossfade groove~ A with groove~ TEMP (started at right offset),
load new file into buffer A, crossfade groove~ TEMP with groove~ A.
If you don't replace several buffers at same time, a single temporary buffer would
do the job.
@SourceAudio, good idea to use the bang when read operation completes (second outlet of buffer~) to trigger the ramp up.
-- Mitch
thanks a bunch guys, the fade/load/fade does quite nicely for what i need!