jass.engine
Class Out

java.lang.Object
  extended by jass.engine.Out
All Implemented Interfaces:
Source
Direct Known Subclasses:
AudioGroove, AudioIn, Constant, ConstantLoopBuffer, ContactForce, ContactForce2, ContactForceN, CrossfadeLoopBuffer, FilteredWavContactForce, GlottalModel, GlottalWave, Impulse, InOut, KarnoppFriction, LoopBuffer, LoopNBuffers, RandOut, RandOutSquared, RandPulses, Silence, Sine, StatPulses, StickSlip, StickSlip0, StickyControl, ThreadMixer

public abstract class Out
extends java.lang.Object
implements Source

Output-only unit. Will produce audio-rate buffers. Needs only implementation of computeBuffer().

Author:
Kees van den Doel (kvdoel@cs.ubc.ca)

Field Summary
protected  float[] buf
          The current buffer.
protected  int bufferSize
          Buffer length of processed audio buffers.
protected  float[] bufOld
          The old buffer.
protected  java.lang.Object lock
          To provide access to the old buffer without locking whole class
 
Constructor Summary
Out()
          Create.
Out(int bufferSize)
          Create at time 0 (which you may want to change by calling setTime() if objects are created in the middle of some jass.sis process).
 
Method Summary
 void clearBuffer()
          Clears buffer to zero.
protected abstract  void computeBuffer()
          Compute the next buffer and store in member float[] buf.
protected  void copyToOld()
           
 float[] getBuffer()
          Get old buffer in cache.
 float[] getBuffer(long t)
          Get buffer with frame index t.
 int getBufferSize()
          Get buffer size.
 long getTime()
          Get current time.
 float[] peekAtBuffer()
          Peek at buffer.
 void resetTime(long t)
          Reset time of self and all inputs
 void setBufferSize(int bufferSize)
          Set buffer size.
 void setTime(long t)
          Set current time.
 void setTimeAndNotify(long t)
          Set current time and notify waiting threads (used by ThreadMixer).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bufferSize

protected int bufferSize
Buffer length of processed audio buffers.


buf

protected float[] buf
The current buffer.


bufOld

protected float[] bufOld
The old buffer.


lock

protected java.lang.Object lock
To provide access to the old buffer without locking whole class

Constructor Detail

Out

public Out(int bufferSize)
Create at time 0 (which you may want to change by calling setTime() if objects are created in the middle of some jass.sis process).


Out

public Out()
Create. Does not allocate bufferSize or set time which is still unknown yet if objects are created in the middle of some jass.sis process).

Method Detail

copyToOld

protected void copyToOld()

peekAtBuffer

public float[] peekAtBuffer()
Peek at buffer. Noone will notice.


getTime

public long getTime()
Get current time.

Specified by:
getTime in interface Source
Returns:
current time.

setTime

public void setTime(long t)
Set current time. Usually called only at init time.

Specified by:
setTime in interface Source
Parameters:
t - current time.

setTimeAndNotify

public void setTimeAndNotify(long t)
Set current time and notify waiting threads (used by ThreadMixer).

Parameters:
t - current time.

resetTime

public void resetTime(long t)
Reset time of self and all inputs

Parameters:
t - time to reset to. Patch must be in a state s.t. none of the current times == t

getBufferSize

public int getBufferSize()
Get buffer size.

Specified by:
getBufferSize in interface Source
Returns:
buffer size in samples.

setBufferSize

public void setBufferSize(int bufferSize)
Set buffer size. Will also reallocate buffer and clear.

Specified by:
setBufferSize in interface Source
Parameters:
bufferSize - buffer size.

computeBuffer

protected abstract void computeBuffer()
Compute the next buffer and store in member float[] buf. This is the core processing method which will be implemented for each generator.


clearBuffer

public void clearBuffer()
Clears buffer to zero.

Specified by:
clearBuffer in interface Source

getBuffer

public float[] getBuffer(long t)
                  throws BufferNotAvailableException
Get buffer with frame index t. Return old buffer if have it in cache. Compute next buffer and advance time if requested, throw exception if requested buffer lies in the past or future. This method will be called "behind the scenes" when processing filtergraphs.

Specified by:
getBuffer in interface Source
Parameters:
t - timestamp of buffer = frame index.
Throws:
BufferNotAvailableException

getBuffer

public float[] getBuffer()
                  throws BufferNotAvailableException
Get old buffer in cache. Deliberately not synchronized.

Specified by:
getBuffer in interface Source
Throws:
BufferNotAvailableException