Changing audio-buffer during pattern performance

Hi,

I built a granulator synthdef that performs on an audio file loaded into a buffer. The synthdef is controlled by a pattern. The audio file is being recorded elsewhere, and appended with new material every few seconds.

I’m currently under the impression that patterns are effectively compiled at run-time. So, when I run my pattern, and reload the audio file into my buffer during pattern playback, it continues to perform on the original loaded buffer----> that is, all the new material that has been appended to my audio file, is not present in the output of pattern playback after I’ve reloaded the audiofile into the same buffer.

Is this impression correct? Are there any obvious strategies for having patterns play back upon a an audio buffer that is frequently changing?

thanks to all !

I think the catch here is that you aren’t reloading the audio file into your buffer – if you’re using Buffer.read, then you’re loading it into a different buffer with a different ID. (Note also that eventually you should free old buffers – memory usage will accumulate otherwise.)

~buf = Buffer.read( /* ... */ );

p = Pbind(
	\bufnum, ~buf,
	/* ... */
).play;

It is true in this case that the Pbind, at creation time, resolved ~buf to a specific Buffer object, and any future reassignment of ~buf will not make a difference.

But, you could populate the buffer number with a pattern that looks up the current value of ~buf.

p = Pbind(
	\bufnum, Pfunc { ~buf },
	/* ... */
).play;

Now the Pfunc is hardcoded into the pattern structure, but a specific value of ~buf is not hardcoded.

hjh

1 Like