Buffer is a special construct that is implemented on a per-wrapper basis. It doesn’t exist as a standalone omni struct, but it only works if the wrapper around omni (like omnicollider and omnimax) implement it. Its purpose is to deal with memory allocated from outside of omni, as it’s the case with SuperCollider’s or Max’s own buffers. Check here for a description on how to write an omni wrapper (including the Buffer interface).

Buffer methods

These are methods that only work in the perform or sample blocks. If used in the init block, they will yield 0:

  1. length : returns the length of the Buffer.
  2. size : returns the total length of the Buffer (length * channels).
  3. chans : returns the number of channels of the Buffer.
  4. samplerate : returns the samplerate of the Buffer.



ins 2:
    "speed" {1, 0.1, 10}

outs: 1

    #One of the ins has to be used in order for omni to point at the specified external buffer.
    #Here it's been set to the first input, "buffer".
    buffer = Buffer(1)
    phase = 0.0

    scaled_rate = buffer.samplerate / samplerate
        out1 = buffer[phase]
        phase += (in2 * scaled_rate)
        phase = phase % float(buffer.len)


After compiling the omni code with

omnicollider MyBuffer.omni

the Buffer interface will work as a regular SuperCollider Buffer. For example:

    b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
    {MyBuffer.ar(b, 1)}.play


Check omnimax’s readme for more information on the calling syntax of Max objects compiled with omni.

After compiling the omni code with

omnimax MyBuffer.omni

the Buffer interface will look like so:

Next: 09 - Stdlib: Delay