/****************************************************************************** * Institution: Stanford University * Project: Sonification * Author: Ryan Cassidy (05157787) * Date: Summer 2003 ******************************************************************************/ /*! \class VocTract * \brief STK class to implement modified Cook tract model. All references to * PRC's thesis below denote the thesis by former CCRMAlite Perry R. Cook. * * VERSION CONTROL INFORMATION: * * $RCSfile: VocTract.h,v $ * * $Author: rjc $ * * $Date: 2003/10/05 05:31:54 $ * * $Locker: rjc $ * * $Log: VocTract.h,v $ * Revision 1.2 2003/10/05 05:31:54 rjc * Added ability to read shapes from file. * VocTract::getk() returns current scattering values. * * Revision 1.1 2003/09/29 21:49:48 rjc * Initial revision * * ******************************************************************************/ #ifndef __VOCTRACT_H #define __VOCTRACT_H #include "Filter.h" #include "Stk.h" #include "DelayA.h" #include "stypes.h" #include <vector> #include <cassert> using namespace std; #define DEFAULT_NUM_SECTIONS 8 struct ShapeRadii { const char *name; const MY_FLOAT radii[DEFAULT_NUM_SECTIONS]; }; class VocTract { public: //! Default constructor initializes vocal tract model to default settings. VocTract(int num_sections = DEFAULT_NUM_SECTIONS); //! Class destructor. ~VocTract(); //! Take sample from glottal waveform, and return sample from lips/nose. MY_FLOAT tick(MY_FLOAT sample); //! Return the number of tract sections in the model (determined in //constructor.) int getNumSections() const {return _num_sections;} //! Set radius of a tract section specified by index (zero-based index). void setSectionRadius(int index, MY_FLOAT radius); //! Set radii of all tract sections. void setRadii(const MY_FLOAT *radii, int num_sections); //! Get radii of all tract sections. const MY_FLOAT *getRadii() const; //! Set length of a tract section specified by index (zero-based index). The //length should be specified in samples of delay. void setSectionLength(int index, MY_FLOAT length); //! Set lengths of all sections. void setLengths(const MY_FLOAT *lengths, int num_sections); //! Get lengths of all sections. const MY_FLOAT *getLengths() const; //! Set phoneme. int setShape(const char *name, ShapeDataSource sds = SHP_FILE); const MY_FLOAT *getk() const {return _k;} void setk(const MY_FLOAT *k, int num_k_vals) { assert(num_k_vals == this->getNumSections()-1); for (int i=0; i<this->getNumSections()-1; i++) { _k[i] = k[i]; } } static const ShapeRadii _shp_radii[2]; protected: //! Clock wave data through the positive and negative going delay lines shown //in Fig. 1.5 of PRC's thesis. MY_FLOAT tractTick(MY_FLOAT sample); static const MY_FLOAT _default_delay_lengths[]; static const MY_FLOAT _default_section_radii[]; int _num_sections; DelayA * _pos_delay; DelayA * _neg_delay; MY_FLOAT _lip_refl, _last_lip_in, _last_out, _lip_refl_gain, _glot_refl_gain, _tract_minus; MY_FLOAT *_k, *_radii, *_lengths; }; #endif