circular buffers and wrap-around reading


    Feb 22 2006 | 3:44 pm
    Hi,
    I'm working with the buffer~ and wave~ objects to try to create a
    circular/continuous buffer. i.e., I have a moving 'window' of sound that
    can be any length and can read from it at any point. I'm most of the way
    there, but there is one issue that doesn't make the window smooth. As
    I'm reading individual samples from the buffer (no need for looping), I
    am using line~ to drive wave~. However, unlike phasor~ which will wrap
    around from the end of the buffer to the beginning, line~ doesn't appear
    to do that. For example, if I have a 5000 ms. buffer, and I specify that
    line~ go from 4000 to 1000, it is going to go backwards and give me a 3
    sec. reverse sample as opposed to wrapping around to give me a 2 sec.
    forward-played sample. Is there any way to get line~ to wrap around or
    to always move forward through a buffer? Many thanks.
    Best,
    Peter

    • Feb 22 2006 | 6:26 pm
      pong~ is what you want for wrapping audio signals into a given range.
      It has two modes: pong and asteroids, (behaves like the ball in the
      old Atari games) but it prefers to refer to them as mode 0 and mode 1.
      However, your problem would be better solved by the abstraction at the
      bottom. All it will do is sort the two values. (if you're always
      going from the minimum to the maximum time, you'll always be reading
      forward.
      Peter McCulloch
      Also, for people craving control-rate pong action, here's PM.Pong:
      max v2;
      Sorting abstraction:
      max v2;
    • Feb 22 2006 | 6:42 pm
      I would recommend an abstraction: mono_line~
      You need to know the direction (monotonacity) and the maximum /
      minimum clip values. You could use pong~ as described before, and if
      the destination is in the wrong direction, add the difference to the
      maximum value (negate all of this for monotonically decreasing line).
      You'll in effect be unwrapping the values and then using pong~ to clip
      your line for you.
      _Mark
    • Feb 22 2006 | 8:09 pm
      great! thanks, i'll check those all out. i assume you can read forward,
      backward, and at different speeds? so pong~ in 'asteroids mode' should
      theoretically give me a smooth two second sample if, in a 5000 ms
      buffer, i read forward from 4000ms to 1000ms (and sound is continuous
      through the wrap-around)? thanks again!
      best,
      peter
    • Feb 22 2006 | 8:44 pm
      Not exactly. Pong~ has no sense of direction. It only operates on a
      signal if it is outside the specified boundaries. However, if you did
      pong~ 1 0 5000 and tried to read from 4000 to 6000 with line~, you
      would do 4000->5000 then 0-1000. (it would wrap) If you feed line~
      5000 to 3000, you would still get that. (so it would play backwards in
      that circumstance)
      You might think about it as an starting offset + width problem rather
      than a start and end problem. (the good news is that the math is easy,
      and makes transposition trivial to implement)
      Peter
    • Feb 22 2006 | 9:25 pm
      On around Feb 22, 2006, at 19:26, Peter McCulloch said something like:
      > pong~ is what you want for wrapping audio signals into a given range.
      > It has two modes: pong and asteroids,
      Yet another tool for wrapping audio signals: lp.scampf, which offers
      three modes: clip, wrap, and reflect, as well as linear and nonlinear,
      symmetrical and asymmetrical mapping of input to output values.
      If I can find some time I'll see if I can whip up a demo patch, but
      this may not happen all too soon...
      > but it prefers to refer to them as mode 0 and mode 1.
      lp.scampf prefers to refer to its modes as clip, wrap, and reflect
      rather than "pong". I've spent too much time among the Brits to want to
      pong.
      -------------- http://www.bek.no/~pcastine/Litter/ --------------
      Peter Castine | ^
      | Litter Power & Litter Bundle for Jitter
      pcastine@gmx.net |
      pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
      4-15@kagi.com | for Max/MSP
      | Extremely cool
      | http://www.dspaudio.com
      | http://www.dspaudio.com/software/software.html
    • Feb 25 2006 | 4:43 pm
      > On around Feb 22, 2006, at 19:26, Peter McCulloch said something like:
      > > pong~ is what you want for wrapping audio signals into a given range.
      > > It has two modes: pong and asteroids,
      > Yet another tool for wrapping audio signals: lp.scampf, which offers
      > three modes: clip, wrap, and reflect, as well as linear and nonlinear,
      > symmetrical and asymmetrical mapping of input to output values.
      >
      > If I can find some time I'll see if I can whip up a demo patch, but
      > this may not happen all too soon...
      Hello,
      I'm interested in the circular buffer/wrapping concept as well and was wondering if there was an example patch out there. I'm not certain what to do with the pm.pong abstract. Is there a help/demo patch of what exactly that abstract does?
      Thanks,
      Doug Michael
    • Feb 26 2006 | 3:05 am
      This should hopefully clarify things.
      thanks,
      Peter McCulloch
      > Hello,
      > I'm interested in the circular buffer/wrapping concept as well and was
      > wondering if there was an example patch out there. I'm not certain
      > what to do with the pm.pong abstract. Is there a help/demo patch of
      > what exactly that abstract does?
      > Thanks,
      > Doug Michael
      >
      max v2;