windowing for simple looper

Dario's icon

I'm trying to make a very simple looper/stutter effect in gen and want to perform some windowing to remove clicks. Basically I am recording one second of audio that is played back by a [phasor] [fold] [sample] combination for the stutter. Only problem is I get terrible clicks and I'd like to window the playback.

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

Evan's icon

There's a few different ways you could do this. You could create an external buffer that defines a window, and apply that to the amplitude of the loop/stutter. You could set up some math that automatically fades in/out the amplitude when the playback gets close the beginning/end of the loop/stutter.

The way you've implemented the playhead for the stutter is a bit wonky (to me, this might be what you are trying to do) - the phasor jumps back to 0 after each second, so you may want to rethink that part, using a counter and folding/wrapping would eliminate that.

Dario's icon

Thanks Evan ill try that out!

Dario's icon

I think the counter part of your suggestion is crucial for this

Evan's icon

I use counters all the time for reading through samples/loops. Using counter and then wrapping that to the size of the loop, then dividing by the length will give you a nice 0 - 1 ramp, which you can use to read through a window buffer using a sample operator.

Dario's icon

The only thing im wondering is how i would trigger the windowing at the right moment. For example if i am using peek to play back and loop say index 157 to 2341 how to i trigger the windowing to occur at the right moment? Maybe using ==157 and/or==2341 to open a gate?

Evan's icon

I wouldn't worry about triggering anything, just read through the window buffer at all times. Massage the playback index to a range of 0 - 1. In this case you would subtract the offset, and then divide by the length to get an index value of 0 - 1. send that value to a sample operator to read through the buffer containing the window. You would have fades at the beginning and end of the window of a certain amount of samples, effectively fading in and out at the edges of the loop.

Dario's icon

Hmm sounds easy enough i will try tonight. Thanks man

Evan's icon

Good luck! Let me know if you get stuck, I'd be happy to help with examples, etc.

Dario's icon

Cool man. Yeah if u wanna post an example that would be cool cuz i will prob be stuck

Dario's icon

How would I create a windowing buffer inside of gen~? Thing is I got it to work but I wanna load this on my OWL pedal so I have to do everything inside gen~ (ie I cannot reference a buffer object inside of MSP).

Another viable alternative would be to do all the windowing using maths instead of using a windowing buffer which would probably also be better because it would be more computationally efficient which is important for the whole OWL thing

Evan's icon

I'm not sure what type of efficiency gains you'll get from doing the math as opposed from reading from a small buffer, but here's an example of each approach:

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

I did an internal data object in gen, and also just used a fold, clip, and divide to get a window from the sample index of a loop.

.quasar's icon

Hi Dario,

I've attached a patch where the windowing is done using math within a codebox. There's 3 functions (some of them come from the gen pulsar examples). There is also a phase offset so that if you want you can do some time stretching and chain 2 or 4 windows with a relative phase offset. The bandwidth parameter is really nice for granular synthesis but for a stutter you might want to keep it low (==1).

There's a really good collection of windows in Graham Wakefield's site : https://grrrwaaa.github.io/gct633/audio.html

gen_windowing.maxpat
text/plain 10.97 KB

Evan's icon

.quasars stuff is better than mine!

user experience's icon

I use counters all the time for reading through samples/loops. Using counter and then wrapping that to the size of the loop, then dividing by the length will give you a nice 0 - 1 ramp, which you can use to read through a window buffer using a sample operator.

Dario's icon

cool Im gonna try these solutions right now.

Also came up with this solution making an almost rectangular window using maths:

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

Roman Thilenius's icon

if you dont mind having a tail at the end of your audio, you can setup only one window and create the others using delays.

(thinking external buffer here, but might also be cool for live generated math functions)