jass.generators
Class ModalObject

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

public class ModalObject
extends InOut

Vibration model of object, capable of playing sound.

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

Nested Class Summary
 class ModalObject.Contact
          Represents contact with location in barycentric coordinates.
 
Field Summary
 ModalModel modalModel
          Modal data.
 float srate
          Sampling rate in Hertz.
 
Fields inherited from class jass.engine.InOut
sourceContainer, sourcePassivity, srcBuffers
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld, lock
 
Constructor Summary
ModalObject(float srate, int nf, int np, int bufferSize)
          Create and initialize, but don't set any modal parameters.
ModalObject(ModalModel m, float srate, int bufferSize)
          Create and initialize with provided modal data.
 
Method Summary
 java.lang.Object addSource(Source s)
          Add a Source.
 void clearHistory()
          Set state to non-vibrating.
protected  void computeBuffer()
          Compute the next buffer and store in member float[] buf.
 void computeFilter()
          Compute the filter coefficients used for real-time rendering from the modal model parameters.
 void computeResonCoeff()
          Compute the reson coefficients from the modal model parameters.
 void removeSource(Source s)
          Remove a Source.
 void setDamping(float dscale)
          Scale dampings.
 void setFrequencyScale(float fscale)
          Scale frequencies.
 void setNf(int nf)
          Reduce number of modes used.
 
Methods inherited from class jass.engine.InOut
addSource, getBuffer, getSources, resetTime
 
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

srate

public float srate
Sampling rate in Hertz.


modalModel

public ModalModel modalModel
Modal data.

Constructor Detail

ModalObject

public ModalObject(float srate,
                   int nf,
                   int np,
                   int bufferSize)
Create and initialize, but don't set any modal parameters.

Parameters:
srate - sampling rate in Hertz.
nf - number of modes.
np - number of locations.
bufferSize - Buffer size used for real-time rendering.

ModalObject

public ModalObject(ModalModel m,
                   float srate,
                   int bufferSize)
Create and initialize with provided modal data.

Parameters:
m - modal model to load.
srate - sampling rate in Hertz.
bufferSize - Buffer size used for real-time rendering.
Method Detail

addSource

public java.lang.Object addSource(Source s)
                           throws SinkIsFullException
Add a Source. Implements Sink interface. Must take into account that may add source while running, so have to set time.

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

removeSource

public void removeSource(Source s)
Remove a Source. Implements Sink interface.

Specified by:
removeSource in interface Sink
Overrides:
removeSource in class InOut
Parameters:
s - Source to remove.

setDamping

public void setDamping(float dscale)
Scale dampings.

Parameters:
d - damping scale.

setFrequencyScale

public void setFrequencyScale(float fscale)
Scale frequencies.

Parameters:
fscale - frequency scale.

setNf

public void setNf(int nf)
Reduce number of modes used.

Parameters:
nf - number of modes to use.

computeFilter

public void computeFilter()
Compute the filter coefficients used for real-time rendering from the modal model parameters.


computeResonCoeff

public void computeResonCoeff()
Compute the reson coefficients from the modal model parameters. Cache values for location computation.


clearHistory

public void clearHistory()
Set state to non-vibrating.


computeBuffer

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

Specified by:
computeBuffer in class Out