jass.engine
Class InOut

java.lang.Object
  extended by jass.engine.Out
      extended by jass.engine.InOut
All Implemented Interfaces:
Sink, Source
Direct Known Subclasses:
AllPass, CombReverb, FilterContainer, FilterContainerStereo, FilterUG, LevelMeter, LowpassColorSonificator, LowPassComb, Mixer, ModalObject, ModalObjectWithOneContact, ModalQuencher, OpenWebsterTube, Rectify, SingleMode, SpatialMixer

public abstract class InOut
extends Out
implements Sink

Input/output unit. Needs only implementation of computeBuffer(). Each attached source can be labeled passive, which means that we will call getBuffer() without a time stamp on it, so no computation is triggered. This is needed only when using the ThreadMixer which would result in deadlocks on closed loops. So you have to explicitly mark source connections passive to eliminate loops. When using only 1 thread this is not needed.

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

Field Summary
protected  java.util.Vector<Source> sourceContainer
           
protected  java.util.Vector<java.lang.Boolean> sourcePassivity
           
protected  float[][] srcBuffers
          Array of buffers of the sources
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld, lock
 
Constructor Summary
InOut(int bufferSize)
           
 
Method Summary
 java.lang.Object addSource(Source s)
          add source to Sink.
 java.lang.Object addSource(Source s, boolean p)
          add source to Sink, can flag as passive (so will trigger no computation)
 float[] getBuffer(long t)
          Get buffer with frame index t.
 Source[] getSources()
          Get array of sources.
 void removeSource(Source s)
          Remove a Source
 void resetTime(long t)
          Reset time of self and all inputs
 
Methods inherited from class jass.engine.Out
clearBuffer, computeBuffer, 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

sourceContainer

protected java.util.Vector<Source> sourceContainer

sourcePassivity

protected java.util.Vector<java.lang.Boolean> sourcePassivity

srcBuffers

protected float[][] srcBuffers
Array of buffers of the sources

Constructor Detail

InOut

public InOut(int bufferSize)
Method Detail

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

addSource

public java.lang.Object addSource(Source s,
                                  boolean p)
                           throws SinkIsFullException
add source to Sink, can flag as passive (so will trigger no computation)

Parameters:
s - Source to add.
passive - flag; true if passive, otherwise will be active (normal)
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.

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 calle "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