com.cycling74.msp
Class MSPBuffer

java.lang.Object
  extended by com.cycling74.msp.MSPBuffer

public class MSPBuffer
extends java.lang.Object

Provides static methods that get and set buffer data. created on 9-April-2004


Method Summary
static int getChannels(java.lang.String name)
          Gets the number of channels.
static long getFrames(java.lang.String name)
          Gets the number of frames (samples) in a buffer.
static double getLength(java.lang.String name)
          Gets the length of a buffer in milliseconds.
static long getSize(java.lang.String name)
          Gets the size (frames*channels) of a buffer.
static float[] peek(java.lang.String name)
          Get the data from an entire buffer with the channels interleaved.
static float[] peek(java.lang.String name, int channel)
          Get an entire channel from a buffer.
static float peek(java.lang.String name, int channel, long index)
          Get a single value from a buffer.
static float[] peek(java.lang.String name, int channel, long start, long length)
          Get a range of values from a buffer.
static void poke(java.lang.String name, float[] val)
          Set all the data in a buffer in interleaved format.
static void poke(java.lang.String name, int channel, float[] val)
          Set a channels worth of data in a buffer.
static void poke(java.lang.String name, int channel, long index, float val)
          Set one data point in a buffer.
static void poke(java.lang.String name, int channel, long start, float[] val)
          Set a range of data in a buffer.
static void setFrames(java.lang.String name, int numchannels, long size)
          Sets the number of frames (samples) in a buffer, and the number of channels.
static void setLength(java.lang.String name, int numchannels, double millis)
          Sets the length of a buffer in milliseconds, and the number of channels.
static void setSize(java.lang.String name, int numchannels, long size)
          Sets the size (frames*channels) of a buffer, and the number of channels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getChannels

public static int getChannels(java.lang.String name)
Gets the number of channels.

Parameters:
name - the name of the buffer
Returns:
the number of channels

setLength

public static void setLength(java.lang.String name,
                             int numchannels,
                             double millis)
Sets the length of a buffer in milliseconds, and the number of channels.

Parameters:
name - the name of the buffer
numchannels - the number of channels for the buffer to have
millis - the length, in milliseconds

getLength

public static double getLength(java.lang.String name)
Gets the length of a buffer in milliseconds.

Parameters:
name - the name of the buffer
Returns:
the length in milliseconds

getFrames

public static long getFrames(java.lang.String name)
Gets the number of frames (samples) in a buffer.

Parameters:
name - the name of the buffer
Returns:
the number of frames in the buffer

setFrames

public static void setFrames(java.lang.String name,
                             int numchannels,
                             long size)
Sets the number of frames (samples) in a buffer, and the number of channels. Note that the execution of this method is always deferred to the main thread.

Parameters:
name - the name of the buffer
numchannels - the number of channels for the buffer to have
size - the length of the buffer, in frames

getSize

public static long getSize(java.lang.String name)
Gets the size (frames*channels) of a buffer.

Parameters:
name - the name of the buffer
Returns:
the size (frames*channels)

setSize

public static void setSize(java.lang.String name,
                           int numchannels,
                           long size)
Sets the size (frames*channels) of a buffer, and the number of channels. If the size is not evenly divided by the number of channels it is rounded down. Note that the execution of this method is always deferred to the main thread.

Parameters:
name - the name of the buffer
numchannels - the number of channels for the buffer to have
size - the new size of the buffer, in samples, to be distributed amongst all the channels

peek

public static float peek(java.lang.String name,
                         int channel,
                         long index)
Get a single value from a buffer. Indexing starts at 0.

Parameters:
name - the name of the buffer
channel - the channel of interest
index - the index within the channel to get
Returns:
the value of the sample at the requested channel and index

peek

public static float[] peek(java.lang.String name,
                           int channel,
                           long start,
                           long length)
Get a range of values from a buffer. Indexing starts at 0.

Parameters:
name - the name of the buffer
channel - the channel of interest
start - the first index of interest
length - the number of samples to return
Returns:
the values of the samples from the requested channel and range

peek

public static float[] peek(java.lang.String name,
                           int channel)
Get an entire channel from a buffer.

Parameters:
name - the name of the buffer
channel - the channel of interest
Returns:
the values of the samples from the requested channel

peek

public static float[] peek(java.lang.String name)
Get the data from an entire buffer with the channels interleaved.

Parameters:
name - the name of the buffer
Returns:
the buffer data with interleaved channels

poke

public static void poke(java.lang.String name,
                        int channel,
                        long index,
                        float val)
Set one data point in a buffer.

Parameters:
name - the name of the buffer
channel - the channel of interest
index - the index to set
val - the new value at the given channel and index

poke

public static void poke(java.lang.String name,
                        int channel,
                        long start,
                        float[] val)
Set a range of data in a buffer.

Parameters:
name - the name of the buffer
channel - the channel of interest
start - the first index in the range
val - the data to write into the buffer

poke

public static void poke(java.lang.String name,
                        int channel,
                        float[] val)
Set a channels worth of data in a buffer.

Parameters:
name - the name of the buffer
channel - the channel of interest
val - the data write into the buffer in the channel of interest

poke

public static void poke(java.lang.String name,
                        float[] val)
Set all the data in a buffer in interleaved format.

Parameters:
name - the name of the buffer
val - the data to write into the buffer, with the channels interleaved.