jass.engine
Class ThreadMixer

java.lang.Object
  extended by jass.engine.Out
      extended by jass.engine.ThreadMixer
All Implemented Interfaces:
Sink, Source

public final class ThreadMixer
extends Out
implements Sink

Mixer that runs a thread on each input. Add sources, then call init() method, then you can use it as a normal mixer. Unlike other UG's you can't add or remove sources while running.

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

Field Summary
 float[][] srcBuffers
           
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld
 
Constructor Summary
ThreadMixer(int bufferSize)
           
 
Method Summary
 java.lang.Object addSource(Source s)
          add source to Sink.
protected  void computeBuffer()
          Compute the next buffer and store in member float[] buf.
 float[] getBuffer(long t)
          Get buffer with frame index t.
 float[] getGains()
          Get input gain control vector.
 Source[] getSources()
          Get array of sources.
 void init()
           
 void removeSource(Source s)
          Remove a Source
 void resetTime(long t)
          Reset time of self and all inputs
 void setGain(int k, float g)
          Set input gain control vector.
 void signalDone()
           
 
Methods inherited from class jass.engine.Out
clearBuffer, copyToOld, getBuffer, getBufferSize, getTime, peekAtBuffer, setBufferSize, setTime, setTimeAndNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

srcBuffers

public float[][] srcBuffers
Constructor Detail

ThreadMixer

public ThreadMixer(int bufferSize)
Method Detail

signalDone

public void signalDone()

setGain

public void setGain(int k,
                    float g)
Set input gain control vector.

Parameters:
k - index of gain
gains - input gain

getGains

public float[] getGains()
Get input gain control vector.

Parameters:
gains - input gains

addSource

public java.lang.Object addSource(Source s)
                           throws SinkIsFullException
add source to Sink.

Specified by:
addSource in interface Sink
Parameters:
s - Source to add.
Returns:
object representing Source in Sink (may be null).
Throws:
SinkIsFullException

removeSource

public void removeSource(Source s)
Description copied from interface: Sink
Remove a Source

Specified by:
removeSource in interface Sink
Parameters:
s - Source to remove

getSources

public Source[] getSources()
Get array of sources.

Specified by:
getSources in interface Sink
Returns:
array of the Sources, null if there are none.

init

public void init()

getBuffer

public final 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
Overrides:
getBuffer in class Out
Parameters:
t - timestamp of buffer = frame index.
Throws:
BufferNotAvailableException

resetTime

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

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

computeBuffer

protected final void computeBuffer()
Compute the next buffer and store in member float[] buf.

Specified by:
computeBuffer in class Out