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.
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.
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?
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 675.3oc0V1zjaBBFG+r4SACmZmllAPwW5s1dp25sdnyN6XLlDZUvQwoocmMe 1q.ZRbWiQ27xraNXBjGg+++wyCvCSrfyEahKffOA9Ivx5gIVV5tTcXU21BlF tIJIrPGFjG+Gw7eAmZ9KY7Fot64kKWFmuE7UVdz8eQ2.fInpOMgJJkIwR4ey hMSGbYhHTBmV8tg7UPvc0wkEJiVy3qtOONRZB01cFZJ.6R0eQcTeQPyP6dG1 BsHpD1GwMy2RAWxCS0yF7y4rvjl+gWlx3UZQaH7AgWv9mNbLoZF1EqQ35fIp NebxD0ioCDX5o5nPX.91Aq8Ks4YWtlzo251DMNNRjlFyMKeeimUJgu.2YFWX OdfZV7B7OsKr6cEpsKPc3hejyjwfuKJjLAG7tzh2eUrDwGOXK4borDy3ohvz rWlsNRgaAOLqXsPtEPOQkZeYpMHwVWa541WEJcjUnjwTghufjQgZoHsX6QAS AaEWo5Agn.SgfGRinf9Pj6qsMwNBhxD+Nt0d98T0fo1lTDyt3Hu9.f2oAPjH QjWOzpgBMyO.gCbU+BU+K7AidKfYOFfgtb.6CaADWG29NVrNmpuTIbfFddz8 OOFH8eiTrEIJ4U6AgZvC.CvmCh7Q6O5DS5MWK3MBhFSwV8MlFTsFF8ZsXSOb vDF+oWQU6XU+soXgnLOpIIodezpDoFQsHt5hA7P0AoGDS0kN.6E9Z1hEw7CO MNksHSv3xZI.tqyUzgpHZqYqaE4NNEQBPynpqGqS4sQzcstAZ04lRO+AnH5H oGxUyKrldMrDe9zaHZ0qU940ldACPQ9iid9AJbYtRSMI8NezQFH55SnOeGKp CF6o2wx2wFa60dGqmXLGSUDxb.hKYWqavZfZC4aXZAYnR5Jh6VVnpwiS9Ofy qw7R -----------end_max5_patcher-----------
Great thanks a lot! Have it working nicely now.
Forums > MaxMSP