Pure Codebox Looper - change buffer name in GEN function => possible ?

jo geisler's icon

Dear all,

I have written a click free one track looper in GEN (please see patcher / works fine :-)).

My goal is it to have 8 loopers in parallel working. To avoid having 8 times the code and also the need to change variable names 8 times I put my code into a function which I understood has the effect that all variables will remain local.

CodeLooperBackup.maxpat
Max Patch


The looper function has 4 arguments up to now: 1 = audio in, 2 = record / play trigger, 3 = reset & 4 = ramp time.

I want now to extend that function in a way that I am able to also specify the buffer name that I want the audio to be written and read.

I this possible?
And If yes could you please provide me a code sample?

Regards

Jo

jo geisler's icon

Found the solution myself last night 1am ;-)

It is possible but the declaration of the buffer needs to be outside the function. Here is the example solution:

// This is the function code: Write one sample at position 1 in the buffer
LOOPER (AudioIn, InBufferName) {
poke(InBufferName,AudioIn,1)
}

//Here is the code that is executing the function
//The name of the buffer inside gen is nameOfBuffer which is referencing the //max map buffer which is called looper
Buffer nameOfBuffer ("looper");
Looper (in1,nameOfBuffer)

With this you can instantiate as many loopers as you want.

I attached also the revised patch.

Regards

Jo

CodeLooperBackup.maxpat
Max Patch

TConnors's icon

Hi Jo,
Nice work on the code gen~ looper.
Did you advance this patch any further since posting in Oct 2017?

Jan Jeffer's icon

Crumbs crumbs