next VoicTract.cpp
up C/C++ Code for VoicTract Class
previous C/C++ Code for VoicTract Class


VoicTract.h

/******************************************************************************
 * Institution: Stanford University
 * Project: Sonification
 * Author: Ryan Cassidy (05157787)
 * Date: Summer 2003
 ******************************************************************************/
/*! \class VoicTract
 *  \brief STK class to implement modified Cook tract model.
 * 
 * VERSION CONTROL INFORMATION:
 * 
 * $RCSfile: VoicTract.h,v $
 *
 * $Author: rjc $
 *
 * $Date: 2003/10/05 05:35:45 $
 *
 * $Locker: rjc $
 *
 * $Log: VoicTract.h,v $
 * Revision 1.2  2003/10/05 05:35:45  rjc
 * Added functions to get number of tract sections.
 * Const-correctness stuff.
 * Added ability to return tube section scattering `k' values.
 *
 * Revision 1.1  2003/09/29 21:49:15  rjc
 * Initial revision
 *
 * 
 ******************************************************************************/

#ifndef __VOICTRACT_H
#define __VOICTRACT_H

#include "Instrmnt.h"
#include "VocTract.h"
#include "SingWave.h"
#include "Envelope.h"
#include "Stk.h"
#include "stypes.h"

#include <string>

using namespace std;

class VoicTract : public Instrmnt
{
 public:
  //! Default constructor.
  VoicTract(int num_tract_sections = DEFAULT_NUM_SECTIONS);

  //! Default destructor.
  virtual ~VoicTract();


/******************************************************************************
 * Functions to set vibrato parameters of voiced glottal waveform.
 ******************************************************************************/
  //! Set amount of vibrato in the input glottal waveform.
  void setVibratoAmt(MY_FLOAT vibratoAmt);

  //! Set the amount of random-ness in the voiced waveform.
  void setRndVibAmt(MY_FLOAT vibratoAmt);


/******************************************************************************
 * Functions to set voiced/unvoiced ratio of glottal waveform.
 ******************************************************************************/
  //! Set the gain of the voiced portion of the sound.
  void setVoiced(MY_FLOAT vGain);
  
  //! Set the gain of the unvoiced portion of the sound.
  void setUnVoiced(MY_FLOAT nGain);

  //! Set both voiced and unvoiced gains.
  void setVoicedUnVoiced(MY_FLOAT vGain, MY_FLOAT nGain);
/******************************************************************************/


  //! Set the rate at which pitches sweep.
  void setPitchSweepRate(MY_FLOAT rate);

  //! Start the singer.
  void speak();

  //! Stop the singer.
  void quiet();

  //! Set the frequency of the underlying glottal waveform.
  void setFreq(MY_FLOAT frequency);

  //! Begin note with specified gain and frequency.
  void noteOn(MY_FLOAT freq, MY_FLOAT amp);

  //! End note currently playing.
  void noteOff(MY_FLOAT amp);

  //! Clock out a sample.
  MY_FLOAT tick();

  //! Control change.
  void controlChange(int number, MY_FLOAT value);

/******************************************************************************
 * Functions to get and set radii of vocal tract sections.
 ******************************************************************************/
  //! Set vocal tract radii.
  void setTractRadii(const MY_FLOAT *radii, int num_sections);

  //! Get tract radii.
  const MY_FLOAT *getTractRadii() const;

  //! Set individual tract section radius.
  void setTractSectionRadius(int sec_index, MY_FLOAT radius);
/******************************************************************************/


/******************************************************************************
 * Functions to get and set lengths of vocal tract sections.
 ******************************************************************************/
  //! Set tube section lengths.
  void setTractLengths(const MY_FLOAT *lengths, int num_sections);

  //! Return tract section lengths.
  const MY_FLOAT *getTractLengths() const;

  //! Set individual tract section length. \e sec_index is a zero-based index.
  void setTractSectionLength(int sec_index, MY_FLOAT length);
/******************************************************************************/


  //! Get number of sections.
  int numTractSections() const;

  //! Set phoneme.
  int setPhoneme(const char *name, ShapeDataSource sds = SHP_FILE)
    {return _tract.setShape(name, sds);}

  const MY_FLOAT *getk() const {return _tract.getk();}

  void setk(const MY_FLOAT *k, int num_k_vals)
    {
      _tract.setk(k, num_k_vals);
    }
 protected:
  VocTract _tract;
  string _resource_path;
  SingWave _voiced;
  Envelope _noise_env;
  OnePole _vib_filt;
  MY_FLOAT _perf_vib_amt, _freq, _last_output;
};

#endif


next VoicTract.cpp
up C/C++ Code for VoicTract Class
previous C/C++ Code for VoicTract Class

``Audio Speech Research Note'', Ryan J. Cassidy, published electronically by author, July 2003.
Download PDF version (audio_speech.pdf)
Download compressed PostScript version (audio_speech.ps.gz)

Copyright © 2003-11-28 by Ryan J. Cassidy.
Please email errata, comments, and suggestions to Ryan J. Cassidy <ryanc@ieee.org>
Stanford University