Base track gradually "eaten away" by intrusions from two different sources - how to make

F_Dos's icon

How to make this idea in MAX?

A base audio track loaded into a buffer. On each bang, I want a short segment somewhere in the base to get overwritten/replaced by a short random segment — but the intruding segment is drawn randomly from one of two different source files each time (so the base gets progressively "invaded" by two different sonic identities, alternating unpredictably).

So per bang:

  1. Randomly pick source file A or B

  2. Grab a random short segment (e.g. 50–300ms) from a random position in that source

  3. Write it into the base buffer at a specific/random position, overwriting what's there

  4. Repeat — over many bangs, the base becomes increasingly eaten away/contaminated by fragments of both sources

I'm guessing this means keeping the base as one mutable buffer that I keep punching new content into over time. Would peek~/poke~ be the way to copy a chunk from a source buffer into a specific spot in the base buffer? Or is there a cleaner/more standard technique for this kind of "overwrite in place" operation?

Also curious about good approaches for:

  • Tracking/randomizing where in the base each intrusion lands

  • Making sure segment boundaries don't click (crossfading in/out at the edges)

  • Any example patches doing something similar (granular-style overwriting/contamination of a fixed buffer)

Thanks


Source Audio's icon

No matter what tool you use to copy and crossfade buffers,

if that base audio file is going to loop, you will definitivelly have clicks

because you can not avoid overwritting current play position with

other audio because length and position is random.

for 50 ms copy length, crossfade depending on audio material would have no effect.

P.S. as first you need to decide if that should run in real time or not.

I would personally prefer to hear when that bang comes in,

and for that one would use current play position and start crossfade and copy from there.

That would make the construct much easier.

otherwise you need to calculate 2 offsets for 2 crossfades

and in case of non real time hear clicks while copying.

F_Dos's icon

Good point, but actually the clicks might be desirable here, not something to avoid. The piece is about a base track getting progressively "eaten away," so cuts/glitches fit the aesthetic. So I'll stick with fully random write positions (not tied to playback position) and skip crossfading.

A few follow-ups:

  • Is poke~ fine for this even without worrying about overlapping the base's own playback position, for short (50-300ms) chunks?

  • Any way to make the "roughness" controllable — dial from clean cuts to full chaos — rather than all-or-nothing?

  • Any pitfalls with repeated poke~ overwrites over a long performance (denormals, timing, etc.)?

Thanks!

Source Audio's icon

Again all is technicslly possible, but you need to make decisions first.

Simply think about it.

Real time copy in case all 3 buffers are same length and allw ays use current play position as destination offset would simplify everything so much that you would need only few objects to do the job, including crossfading.

If you instead want to make non real time source, destination, lenght completely randomised, you will need to care about sample count boundaries of a buffer.

For example if you want to copy 500ms

starting from 100ms before source end

and copy that at position 200ms before destination buffer end, you have to deal

with portions that sre not continuos

and breeak fading and cooying into more parts.

in case of real time sample count you only need to set start offset

Again, think a bit about this technical aspects

before one waists time

Source Audio's icon

And sorry but that roughness you mention makes no sense in this context, you overwritte the buffer or not, what is in between ?

F_Dos's icon

Fair enough on the roughness comment, you're right that it's binary (overwrite or not) — I was overcomplicating it. I'll go with the real-time approach. Simpler, and it still gets me the "contamination" effect I'm after, just via the clicks that naturally happen at each write boundary rather than a tunable parameter. Thanks for pushing on that.

Source Audio's icon

I only have short time at evenning access to my macbook and then post an example.

But idea is this:

3 buffers of same length A B C

B & C are copy sources

Buffer A is played using count- and index-

When you bang , source buffer, lenght of copy portion and copy offset get selected randomly.

Gate opens to pass samplecount to 2 indexes and poke to crreate crossfades and copy for set time.

Index that plays copy source buffer gets offset

which was randomly generated

Source Audio's icon

3 buffers need to be same length. trigger info to get buffer A length.

That sets other parameters.

crossfade is 10 ms, copy time 50 ~ 500 ms random length

Max Patch
Copy patch and select New From Clipboard in Max.

One could also use B & C buffers of different size, but then on every copy, random offset time and sample count loop wrap needs to be recalculated