Cabbage Logo
Back to Cabbage Site

Best way to replace contents of existing ftable with zeros

I’m storing audio in an ftable in my UDO. I want to have a “clear” button that will zero it out if needed.

I have an approach that works, but I don’t really like it. Basically, I’ve created another ftable of the same size and use tablecopy:

tablecopy idelay_buf, idelay_clr

I don’t like it because the idelay_clr table is also big and tablecopy itself seems slow.

Is there a way to reinitialize the ftable instead?

Thank you!

Maybe the table of zeroes can be very short? If so, that could do it.

Is there a more efficient way?

I’m not sure if it’s the most sensible approach, but I often call ftgen again to overwrite an existing table. You’ll get a warning about replacing an existing table, but seems fairly benign.

I have the same question, but clearing an array instead of an ftable.

I’m using a k-array in a UDO to store a delay buffer. It works great, except when I need to clear the buffer (zeroing out the array).

I’ve tried things like:

if kTrigClear == 1 then
     kdelay_line = 0
endif

The issue with this is that the clearing completely takes over the performance of the plugin. All of my other audio is temporarily suspended while it clears the array. And any latency introduced sticks around. Really bad.

I could do it element by element while it runs, but if the buffer is 60 seconds, I don’t want to wait that long to clear the buffer.

Any suggestions? Thank you!

Right now, my code is structured so that the delay line is created/modified in the UDO. In the instrument, I call four copies of the UDO so there are four delay lines.

Would it make more sense to have each delay line called by a different instrument? Maybe I could then create/destroy the instruments as needed?

I think that would make things a lot more modular.

What is the actual purpose of clearing the delay line? In my mind, a cleared delay line results in silence which could be easily achieved by muting the output. So maybe the delay lines don’t need to be cleared at all, but simply overwritten when needs be :thinking:

That’s a good point. I haven’t made the distinction between “overdub” and “replace” yet. “Replace with silence while muted” would clear things in real time.

That said, I do some things where I jump around the buffer in different ways (reversing, playing back at double speed, nudging the audio), so it is possible the user would end up in a non-cleared region of the buffer.