jass.generators
Class RightLoadedWebsterTube

java.lang.Object
  extended by jass.generators.RightLoadedWebsterTube
All Implemented Interfaces:
Filter, TwoMassModel.PressureServer

public class RightLoadedWebsterTube
extends java.lang.Object
implements Filter, TwoMassModel.PressureServer

Author:
Kees van den Doel (kvdoel@cs.ubc.ca) Implement Webster equation with open left end where velocity is prescribed (glottal source) and right side terminated in baffle in infinite plane. Physical quantities (capitals) are P (pressure) RHO (density) PHO0 (equilibrium density) U velocity, F force/volume on fluid, S area of tube. c is sound speed. L length of tube [0 L]. Dimensionless quantities u,p, and f of dimension 1/m^2 are introduced: RHO=RHO0*(1+p) U = c*u f = F/(c*RHO0) To translate between these and Peter Birkholz's varaibles (Interspeech 04 and thesis): (S = area, C = circumferencem, h = segment length). Peter Kees u/(cS) u p/(rho c^2) p 2*S*R_i/(h*rho) d(S) u_w h*C*z u_{N+1} cS(L)v u_{N+2} cS(L)w Continuum eq. are: du/dt + c*dp/dx + (dWall*c/sqrt(S))*u - (dSecond*c/sqrt(S))* d^2u/dx^2 = f(x,t) [1a] d(Sp)/dt + c*d(Su)/dx = - C(x)*z [1b] M dz/dt + Bz + Ky = p [1c] dy/dt = z [1d] u(0) = ug (given source: glottal velocity) [1e] u(L) = v. [1f] where C(x) is the circumference. In the paper AscherDoel07 we call (dWall*c/sqrt(S))=d(S). v satisfies eq. for radiation impedance: v = dw/dt*L_R/R_R + w, [2a] dw/dt = rho*c/(L_R*S_end) * p(L) [2b] ( Birkholz has this in the form where on LHS of [2b] there are extra terms h*rho/(2*L_R*S) dv/dt + h*rho*d(S)/(2*L_R*S) v ) where (c.f. Birkholz Interspeech 04) L_R = 8 rho/(3pi sqrt(pi S_end) R_R = 128rho c/(9 pi^2 S_end). M = Mw/(rhoc^2) B = Bw/(rhoc^2) K = Kw/(rhoc^2) with Mw=21, Bw=8000, Kw=845000 (see Birkholz 04). In the code w is called u_N2 and v is pu[N-1] (i.e., last element in array). dWall is an attenuation factor, as is dSecond. Discretization with staggered grid, u on even points, p on odd, S on both. Grid of N points x = i*h, N odd, grid space h. The wall vibration parameters z,y live on the same nodes as pressure. CFL condition is: eta = c*dt/2h < 1. Or h = c*dt/(2*eta). We would expect the cutoff freq. to be (eta/2)*Fs with Fs sampling rate. In practice the cutoff is lower, about (eta/2.5) * Fs. (Why?) We determine N from the minimum L we want to simulate, then increase h when appropriate for longer tubes. To get freq. up to (roughly) srate/2 resolved we have to oversample with a factor 2. Grid state vector x(i) i = 0,...,N-1: (NB N is odd) x(i) = u(i*h) i=0,2,...,N-1 x(i) = p(i*h) i=1,3,...,N-2 0 1 2 3 4 5 6 (N=7,NNasal=5) u p u p u p u uN[0] pN[1] uN[2] pN[3] uN[4] Discretize Eq. 1a-e using symplectic Euler, i.e., update u first, then update p in terms of the new u's. Note that the last u is really the u outside the lips so the actual length of the tract is up to the last pressure. Nasal tract id coupled at a pressure pivot point, so the nasal tract has an odd number NNasal of grid points starting with a velocity point coupled to the pivot pressure. So if the area SNasal[0] (leftmost) is zero the nasal tract decouples. Theoretically we need a damping dW(om) * c/sqrt(S) with freq. dependent dW given by (see Birkholz 04) dW(om)=sqrt[pi * mu*om/(rho c^2)]. We can approximate by dWall*c/sqrt(S) * u - dSecond*c/sqrt(S) * u_xx and chose dWall and dSecond to match as closely as possible. So make them equal at om1 and om2. This results in dSecond = [dW(om2)-dW(om1)]/[(om2/c)^2-(om1/c)^2] dWall = dW(om1) - dSecond*(om1/c)^2

Field Summary
protected  double[] aa
           
protected  double[] bb
           
protected  double BWall
           
protected  double c
           
protected  double[] cc
           
protected  double CFLNumber
           
 double d
           
protected  double[] dd
           
 double dSecond
           
protected  double dt
           
 double dWall
           
 double dWallNasal
           
protected  double eta
           
protected  double etaNasal
           
protected  double flowNoiseBandwidth
           
protected  double flowNoiseFrequency
           
protected  double flowNoiseLevel
           
protected  double h
           
protected  double hMin
           
protected  double hMinNasal
           
protected  double hNasal
           
protected  int iNasal
           
protected  double KWall
           
protected  double len
           
protected  double lenNasal
           
 double lipAreaMultiplier
           
 double M
           
protected  double minLen
           
protected  double minLenNasal
           
 double mouthNoseBalance
           
 double multD
           
 double multDSecond
           
 double multDWall
           
 double multM
           
protected  double muVisc
           
protected  double MWall
           
protected  int N
           
protected  int nn
           
protected  int NNasal
           
protected  int nnNasal
           
 double om1
           
 double om2
           
protected  double[] outBuf
           
protected  int overSamplingFactor
           
protected  double[] pu
           
protected  double[] pu_noise
           
protected  double[] pu_old
           
protected  double[] puNasal
           
protected  double relativeLocationOfNasalTract
           
protected  double[] S
           
protected  double[] SNasal
           
protected  double[] Snow
           
protected  double[] SnowNasal
           
protected  double[] Sold
           
protected  double[] SoldNasal
           
protected  double[] Sprev
           
protected  double[] SprevNasal
           
protected  double[] sqrtS
           
protected  double[] sqrtSNasal
           
protected  double[] sqrtSold
           
protected  double[] sqrtSoldNasal
           
protected  float srate
          Sampling rate in Hertz.
protected  TubeShape tubeShape
           
protected  TubeShape tubeShapeNasal
           
protected  boolean twoMassCouplingOn
           
protected  TwoMassModel twoMassModel
           
protected  double u_N2
           
protected  double u_N2_nose
           
 boolean useLipModel
           
 double velumNasal
           
protected  double wallPressureCoupling
           
protected  double[] yWall
           
protected  double[] yWallNasal
           
protected  double[] zWall
           
protected  double[] zWallNasal
           
 
Constructor Summary
RightLoadedWebsterTube(float srate, TubeShape tm, double minLen)
           
RightLoadedWebsterTube(float srate, TubeShape tm, double minLen, TubeShape tmNasal, double minLenNasal)
           
RightLoadedWebsterTube(float srate, TubeShape tm, double minLen, TubeShape tmNasal, double minLenNasal, double cflNumber)
           
 
Method Summary
 void allocate()
           
 void changeTubeModel()
           
protected  void computeDampingPars()
           
 void filter(float[] output, float[] input, int nsamples, int inputOffset)
          Proces input (may be same as output).
 void filterIMEX(float[] output, float[] input, int nsamples, int inputOffset)
          Uses IMEX Euler as in paper with Uri Ascher
 double getA1()
          Implement TwoMassModel.PressureServer
 double getCFLNumber()
           
 double getFlowNoiseBandwidth()
           
 double getFlowNoiseFrequency()
           
 double getFlowNoiseLevel()
           
 boolean getOutputVelocity()
           
 double getPressure()
          Implement TwoMassModel.PressureServer
 TwoMassModel getTwoMassModel()
           
 double getWallPressureCoupling()
           
 void reset()
           
 void setCFLNumber(double val)
           
 void setFlowNoiseBandwidth(double v)
           
 void setFlowNoiseFrequency(double v)
           
 void setFlowNoiseLevel(double v)
           
 void setOm1(double val)
           
 void setOm2(double val)
           
 void setOutputVelocity(boolean val)
           
 void setTwoMassModel(TwoMassModel twoMassModel)
           
 void setWallPressureCoupling(double val)
           
protected  void updateFlowFilter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

srate

protected float srate
Sampling rate in Hertz.


minLen

protected double minLen

minLenNasal

protected double minLenNasal

c

protected double c

wallPressureCoupling

protected double wallPressureCoupling

MWall

protected double MWall

BWall

protected double BWall

KWall

protected double KWall

muVisc

protected double muVisc

om1

public double om1

om2

public double om2

len

protected double len

lenNasal

protected double lenNasal

velumNasal

public double velumNasal

h

protected double h

hMin

protected double hMin

hNasal

protected double hNasal

hMinNasal

protected double hMinNasal

N

protected int N

NNasal

protected int NNasal

M

public double M

d

public double d

lipAreaMultiplier

public double lipAreaMultiplier

multM

public double multM

multD

public double multD

dWall

public double dWall

multDSecond

public double multDSecond

multDWall

public double multDWall

dSecond

public double dSecond

S

protected double[] S

Sold

protected double[] Sold

Snow

protected double[] Snow

Sprev

protected double[] Sprev

sqrtS

protected double[] sqrtS

sqrtSold

protected double[] sqrtSold

pu

protected double[] pu

yWall

protected double[] yWall

zWall

protected double[] zWall

u_N2

protected double u_N2

u_N2_nose

protected double u_N2_nose

pu_old

protected double[] pu_old

pu_noise

protected double[] pu_noise

aa

protected double[] aa

bb

protected double[] bb

cc

protected double[] cc

dd

protected double[] dd

nn

protected int nn

nnNasal

protected int nnNasal

tubeShape

protected TubeShape tubeShape

dWallNasal

public double dWallNasal

SNasal

protected double[] SNasal

SoldNasal

protected double[] SoldNasal

SnowNasal

protected double[] SnowNasal

SprevNasal

protected double[] SprevNasal

sqrtSNasal

protected double[] sqrtSNasal

sqrtSoldNasal

protected double[] sqrtSoldNasal

puNasal

protected double[] puNasal

yWallNasal

protected double[] yWallNasal

zWallNasal

protected double[] zWallNasal

tubeShapeNasal

protected TubeShape tubeShapeNasal

outBuf

protected double[] outBuf

relativeLocationOfNasalTract

protected double relativeLocationOfNasalTract

iNasal

protected int iNasal

overSamplingFactor

protected int overSamplingFactor

useLipModel

public boolean useLipModel

dt

protected double dt

eta

protected double eta

etaNasal

protected double etaNasal

mouthNoseBalance

public double mouthNoseBalance

twoMassModel

protected TwoMassModel twoMassModel

twoMassCouplingOn

protected boolean twoMassCouplingOn

CFLNumber

protected double CFLNumber

flowNoiseLevel

protected double flowNoiseLevel

flowNoiseBandwidth

protected double flowNoiseBandwidth

flowNoiseFrequency

protected double flowNoiseFrequency
Constructor Detail

RightLoadedWebsterTube

public RightLoadedWebsterTube(float srate,
                              TubeShape tm,
                              double minLen)

RightLoadedWebsterTube

public RightLoadedWebsterTube(float srate,
                              TubeShape tm,
                              double minLen,
                              TubeShape tmNasal,
                              double minLenNasal)

RightLoadedWebsterTube

public RightLoadedWebsterTube(float srate,
                              TubeShape tm,
                              double minLen,
                              TubeShape tmNasal,
                              double minLenNasal,
                              double cflNumber)
Method Detail

setCFLNumber

public void setCFLNumber(double val)

getCFLNumber

public double getCFLNumber()

setOutputVelocity

public void setOutputVelocity(boolean val)

setOm1

public void setOm1(double val)

setOm2

public void setOm2(double val)

setWallPressureCoupling

public void setWallPressureCoupling(double val)

getWallPressureCoupling

public double getWallPressureCoupling()

computeDampingPars

protected void computeDampingPars()

getOutputVelocity

public boolean getOutputVelocity()

allocate

public void allocate()

getTwoMassModel

public TwoMassModel getTwoMassModel()

setTwoMassModel

public void setTwoMassModel(TwoMassModel twoMassModel)

changeTubeModel

public void changeTubeModel()

reset

public void reset()

setFlowNoiseLevel

public void setFlowNoiseLevel(double v)

getFlowNoiseLevel

public double getFlowNoiseLevel()

setFlowNoiseFrequency

public void setFlowNoiseFrequency(double v)

getFlowNoiseFrequency

public double getFlowNoiseFrequency()

setFlowNoiseBandwidth

public void setFlowNoiseBandwidth(double v)

getFlowNoiseBandwidth

public double getFlowNoiseBandwidth()

updateFlowFilter

protected void updateFlowFilter()

getPressure

public double getPressure()
Implement TwoMassModel.PressureServer

Specified by:
getPressure in interface TwoMassModel.PressureServer

getA1

public double getA1()
Implement TwoMassModel.PressureServer

Specified by:
getA1 in interface TwoMassModel.PressureServer

filter

public void filter(float[] output,
                   float[] input,
                   int nsamples,
                   int inputOffset)
Proces input (may be same as output). Implements Filter interface

Specified by:
filter in interface Filter
Parameters:
output - user provided buffer for returned result.
input - user provided input buffer.
nsamples - number of samples written to output buffer.
inputOffset - where to start in circular buffer input (unused)

filterIMEX

public void filterIMEX(float[] output,
                       float[] input,
                       int nsamples,
                       int inputOffset)
Uses IMEX Euler as in paper with Uri Ascher