Evelope-Triggered Reverse Delay

Mark D.'s icon

So I'm fairly new to Max and Gen in general, but I am interested in building a patch for my Owl effects pedal that allows you to use patches you create in Gen. Unfortunately, it restricts you to Gen (as far as I know), so I have to work within the limitations.

I have this idea to finally get around the issue of reverse delay effects always having trouble being in sync with a tempo. The plan is to make a looper/sampler that starts recording when your signal exceeds a threshold and stops when it reaches the end of the defined time (tap tempo or predefined). It would immediately start playing in reverse until it reached the recording's end (beginning?). If you wanted to increase feedback I could add a delay after that that would be the same length as the sampler's time. Either way, this would negate the issue of the imperfect timing of the buffer's cutoff, and would make it work more like a regular delay where the timing doesn't need to be exact.

So here's where I'm at: I'm still pretty noobish, but after poking around on the forums and looking at some example patches, I understand that Gen uses the data and buffer objects to store a sample, however buffer references an external buffer in Max, which wouldn't work due to my Gen-only limitations. So that leaves the data object. My problem is that I can't find any examples of the data object being used as a sampler except for the "slicer" example patch where it is used to also play with the pitch. Unfortunately, after a day or so of messing with different objects and numbers in the patch and looking up references for all the object's definitions, I've found it's very intimidating and too complex for me to parse through and figure out what parts contribute to the pitch shift and which to the sampler.

I know I'm going to have to take this one step at a time, so, before I even start on the audio envelope triggering, I need a base of how to make a simple 1 repeat delay from a data object. Or (even better) how to create a simple 1 repeat reverse delay from a data object.

I want to better understand Gen and Max and make more things, but I'm having trouble with this first project when I can't find any tutorials or examples on how the data object is constructed and works. A lot of the descriptions seem to give me four or five more questions.

Thanks in advance!

Here is the default Max patch that represents the knobs and push button on the pedal.

Evan's icon

I also have an owl, and I admittedly haven't made anything of consequence for it yet, but i am familiar with doing things in gen~, so this was a good reminder that I need to start digging back into this stuff.
Using the data object is pretty similar to using the buffer. The syntax is generally similar (name, length, number of channels), and the peek/poke objects used for writing/reading samples into the buffer will be identical.
Here's a patch that demonstrates (as quickly and basically as I could, so it's not perfect) how to write, samples into a data object, read those samples out of a data object and be able to reverse it.

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

That should be enough to get you started (replace the time and dir parameters with A, B, C, etc. of course)

Mark D.'s icon

Thank you so much for your help. I can't even check it out yet unfortunately, since I'm going on my honeymoon for two weeks (Japan!). I'll report back when I get home!