Waveform~ update from right to left in GRM Tools Freeze style

Dec 31, 2010 at 1:23pm

Waveform~ update from right to left in GRM Tools Freeze style

Does anyone know how I could get waveform~ to stream the contents of a constantly updating buffer backwards?

This is essentially to mimic the GRM Tools Freeze waveform movement.

So the first sample should enter on the right-hand side of waveform~ and then keep shifting toward the left as new samples continue to enter from the right.

Any help would be great.

Jan 1, 2011 at 8:00am

You should have a second buffer~ just for displaying purposes and fill it backwards. You should use count~ to change the recording position within the buffer. However I think count~ cannot count downwards (I can’t check now). You can insert a !-~ object between count~ and poke~ to reverse counting direction.

Jan 1, 2011 at 2:43pm

Hi Roald, thanks for the answer.

I tried doing that but that just reverses the buffer which isn’t actually what i’m trying to do.

I am trying to get the waveform to enter from the right-hand side and then shift across to the left so that the first sample eventually ends up on the left-hand side. So every new sample that enters will begin on the right side of waveform~ and continually shift across as new samples enter.

Do you know how I could achieve this?

Jan 1, 2011 at 4:38pm

Try writing working with a double circular buffer (to do this write twice at a constant interval apart in samples into a buffer in a cyclical manner – see patch below), and then, instead of moving things within the buffer, move your read point (or using waveform~ the display points). This will be more efficient than moving stuff around in memory all the time, and more inline with the way one would expect to see it done in a text-based language.

The reason to write twice is that you can then read the maximum circular buffer length (half the length of your actual buffer) contiguously at any time (otherwise it wraps around in the middle).

Here’s a circular buffer patch that might get you started
The patch is only good up to 2^23 samples (as far as I recall) because a 32 bit float can’t exactly represent integers above twice this, and you need to write in two places (halving your maximum size). Whatever size I’ve used in the patch should work. If you need a longer buffer then you would need to look at the high res (hr) objects by jkc.

– Pasted Max Patch, click to expand. –



Jan 1, 2011 at 11:10pm

Great thanks a lot! Have it working nicely now.


You must be logged in to reply to this topic.