Dynamically generating windows in gen~

Evan's icon

Hey all,

I'm reworking a patch that I'm trying to dynamically generate a window of a changing length. I ran into a roadblock when trying to do this, and tried to simplify the it in the attached patch. Can someone explain why the gen code on the left doesn't give increasing values from 0 -1?

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

Thanks in advance!

ak's icon

The order of arguments - first value, then index. Try: poke(window, i/127, i, 0);

Evan's icon

wow. Thanks for that. I wonder how long that would've taken me to sort out on my own...

ak's icon

I was just a fresh pair of eyes. Cheers:)

jo geisler's icon

Hello Evan,

as I understood (hope ;-)) you solved the problem with click less loops with windowing I would love to get your insights / code about implementing that into my solution.

I have a simple gen buffer peek poke counter combination as a loop recorder / player. I would like to avoid the clicks at the beginning and the end. I see different combinations possible, please comment based on your experiences if possible and I would also be very happy if you could give me some advice how to code that into gen.

Possible way (like to hear your comments / experiences):

- Envelope Following & Ramping down / up: Recording a ramp beginning with 0 amplitude over a period of e.g 64, 128 samples, following the current input signal, until the ramp reaches the current signal amplitude from the input. The same happens when I stop recording. A ramp down from the current signal amplitude to 0 is being recorded over a period of e.g 64, 128 samples. With this I would suppose no clicks are there any more when playing this loop.

Here is my current patch (pretty basic).

BR

Example.maxpat
Max Patch
Example

Jo

Evan's icon

I would forget about envelope following, as I don't really see the benefits in this case, and its xtra calculations.
You could scale the input amplitude with a ramp going from 0 -1 and 1-0 over the defined amount of samples.
Or you could scale the output, and this might give you more accurate looping (the extra 64 /128 samples at the end could add up over time).

jo geisler's icon

Thanks Evan for your POV.
I will try out.

jo geisler's icon

Evan, tried out and you were right: it got perfect results with scaling the output - no clicks at all when I am looping any sound source. So there is no need to go down the path of zero crossing or envelope following to get a click free looper :-)

Evan's icon

Great to hear!