net.beadsproject.beads.data
Class Buffer

java.lang.Object
  extended by net.beadsproject.beads.data.Buffer
All Implemented Interfaces:
java.io.Serializable

public class Buffer
extends java.lang.Object
implements java.io.Serializable

A Buffer stores a one-dimensional buffer of floats for use as a wavetable or a window. Buffer does not perform any interpolation in this version, you should just make sure your buffer is high-res enough for what you need. Could add interpolation easily if needed.

Author:
ollie
See Also:
BufferFactory, Serialized Form

Field Summary
 float[] buf
          The buffer data.
static Buffer NOISE
           
static Buffer SAW
           
static Buffer SINE
           
static Buffer SQUARE
           
static java.util.Hashtable<java.lang.String,Buffer> staticBufs
          A static storage area for common buffers, such as a sine wave.
static Buffer TRIANGLE
           
 
Constructor Summary
Buffer(int size)
          Instantiates a new buffer.
 
Method Summary
 float getValueFraction(float fraction)
          Returns the value of the buffer at the given fraction along its length (0 = start, 1 = end).
 float getValueIndex(int index)
          Returns the value of the buffer at a specific index.
 java.lang.String toString()
          Returns the contents of the buffer as a String over one line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

staticBufs

public static java.util.Hashtable<java.lang.String,Buffer> staticBufs
A static storage area for common buffers, such as a sine wave. Used by BufferFactory to keep track of common buffers.


SINE

public static final Buffer SINE

SAW

public static final Buffer SAW

SQUARE

public static final Buffer SQUARE

TRIANGLE

public static final Buffer TRIANGLE

NOISE

public static final Buffer NOISE

buf

public final float[] buf
The buffer data.

Constructor Detail

Buffer

public Buffer(int size)
Instantiates a new buffer.

Parameters:
size - the size of the buffer.
Method Detail

getValueFraction

public float getValueFraction(float fraction)
Returns the value of the buffer at the given fraction along its length (0 = start, 1 = end).

Parameters:
fraction - the point along the buffer to inspect.
Returns:
the value at that point.

getValueIndex

public float getValueIndex(int index)
Returns the value of the buffer at a specific index. If index is outside the range, then it is clipped to the ends.

Parameters:
index - the index to inspect.
Returns:
the value at that point.

toString

public java.lang.String toString()
Returns the contents of the buffer as a String over one line.

Overrides:
toString in class java.lang.Object
Returns:
Buffer as String.