jass.generators
Class SingleMode

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

public class SingleMode
extends InOut

Vibration model of object with 1 mode Changes in freq damping and gains are linearly changed over one buffer rather than abruptly

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

Field Summary
protected  float a
          modal parameters
protected  float ampR
          Reson filter gain.
protected  float c_i
          Cached values.
protected  float cutoffRiseExcitation
          Cutoff excitation pulse strength above which a bubble is considered rising
protected  float d
          modal parameters
protected  float f
          modal parameters
protected  float f_base
          modal parameters
protected  float f_rise
          modal parameters
protected  float R2
           
 float srate
          Sampling rate in Hertz.
protected  float[] tmpBuf
          Temp storage
protected  float twoRCosTheta
          The transfer function of a reson filter is H(z) = 1/(1-twoRCosTheta/z + R2/z*z).
protected  float xi
          xi factor for rising bubbles as explained in paper
protected  float yt_1
          State of filter
protected  float yt_2
          State of filter
 
Fields inherited from class jass.engine.InOut
sourceContainer, sourcePassivity, srcBuffers
 
Fields inherited from class jass.engine.Out
buf, bufferSize, bufOld, lock
 
Constructor Summary
SingleMode(float f, float d, float a, float srate, int bufferSize)
          Create and initialize with provided modal data.
SingleMode(float srate, int bufferSize)
          Create and initialize, but don't set any modal parameters.
SingleMode(int bufferSize)
          Constructor for derived classes to call super
 
Method Summary
 java.lang.Object addSource(Source s)
          Add a Source.
protected  void computeBuffer()
          Compute the next buffer and store in member float[] buf.
protected  void computeModalFilterBank(float[] output, float[] force, int nsamples)
          Apply external force[] and compute response through bank of modal filters.
 void computeResonCoeff()
          Compute the reson coefficients from the modal model parameters.
 void setDamping(float d)
          Set damping
 void setFreq(float f)
          Set freq
 void setGain(float a)
          Set gain
 void setRiseCutoffExcitation(float x)
          Set xi value for rising bubbles
 void setXi(float x)
          Set xi value for rising bubbles
 
Methods inherited from class jass.engine.InOut
addSource, getBuffer, getSources, removeSource, 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.


xi

protected float xi
xi factor for rising bubbles as explained in paper


cutoffRiseExcitation

protected float cutoffRiseExcitation
Cutoff excitation pulse strength above which a bubble is considered rising


twoRCosTheta

protected float twoRCosTheta
The transfer function of a reson filter is H(z) = 1/(1-twoRCosTheta/z + R2/z*z).


R2

protected float R2

ampR

protected float ampR
Reson filter gain.


c_i

protected float c_i
Cached values.


f

protected float f
modal parameters


f_rise

protected float f_rise
modal parameters


f_base

protected float f_base
modal parameters


d

protected float d
modal parameters


a

protected float a
modal parameters


tmpBuf

protected float[] tmpBuf
Temp storage


yt_1

protected float yt_1
State of filter


yt_2

protected float yt_2
State of filter

Constructor Detail

SingleMode

public SingleMode(int bufferSize)
Constructor for derived classes to call super

Parameters:
bufferSize - Buffer size used for real-time rendering.

SingleMode

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

Parameters:
srate - sampling rate in Hertz.
bufferSize - Buffer size used for real-time rendering.

SingleMode

public SingleMode(float f,
                  float d,
                  float a,
                  float srate,
                  int bufferSize)
Create and initialize with provided modal data.

Parameters:
f - freq.
d - damping
a - gain
srate - sampling rate in Hertz.
bufferSize - Buffer size used for real-time rendering.
Method Detail

setXi

public void setXi(float x)
Set xi value for rising bubbles

Parameters:
x - xi value (0.1 is normal)

setRiseCutoffExcitation

public void setRiseCutoffExcitation(float x)
Set xi value for rising bubbles

Parameters:
x - excitation value above which bubble is considered rising

addSource

public java.lang.Object addSource(Source s)
                           throws SinkIsFullException
Add a Source. Overrides Sink interface implementation from InOut. Allow only one Source.

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

computeResonCoeff

public void computeResonCoeff()
Compute the reson coefficients from the modal model parameters. Cache values used in #setLocation.


computeBuffer

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

Specified by:
computeBuffer in class Out

setDamping

public void setDamping(float d)
Set damping

Parameters:
d - damping scale.

setFreq

public void setFreq(float f)
Set freq

Parameters:
f - freq.

setGain

public void setGain(float a)
Set gain

Parameters:
a - gain

computeModalFilterBank

protected void computeModalFilterBank(float[] output,
                                      float[] force,
                                      int nsamples)
Apply external force[] and compute response through bank of modal filters. Interpolate filter parameters over the buffer. c[k]=k*(c_new-c_old)/nsamples + c_old

Parameters:
output - user provided output buffer.
force - input force.
nsamples - number of samples to compute.