Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ola_unit.h

Go to the documentation of this file.
00001 /* cm_unit.h    $Revision: 1.2 $ $Date: 2005/12/10 20:33:54 $
00002    Copyright (C) 2003 University of Bonn.
00003    http://www.ikp.uni-bonn.de/boss
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA  02111-1307, USA.
00019 */
00020 
00031 #ifndef OLA_UNIT_H
00032 #define OLA_UNIT_H
00033 
00034 #include <string>
00035 #include <vector>
00036 #include <algorithm>
00037 #include <sstream>
00038 #include <fstream>
00039 #include <iostream>
00040 #include <cmath>
00041 #include <cstdio>
00042 
00043 #include "boss_utility/boss_exceptions.h"
00044 #include "boss_utility/boss_utility.h"
00045 #include "boss_utility/boss_config.h"
00046 #include "boss_utility/dom_userdata.h"
00047 #include "boss_utility/dom_tools.h"
00048 #include <xercesc/dom/DOM.hpp>
00049 #include "boss_mysql/boss_mysql_handler.h"
00050 #include "tdsp/dsp_vector.h"
00051 #include "tdsp/dsp_weight_window.h"
00052 
00053 #include "boss_conman/conman_unit.h"
00054 #include "sampled_signal.h"
00055 #include "pitchmarks.h"
00056 #include "ola_frame.h"
00057 
00058 #define BOSS_PAUSE_SYMBOL "$p"
00059 #define DEFAULT_PAUSE 8000
00060 #define DEFAULT_PAUSE_STRING "8000"
00061 #define MAXIMAL_PAUSE 32000
00062 #define LEFTRIGHTOL 500
00063 #define SMOODIST 17 // the size of 1/4 of a hanning window for smoothing
00064 #define SAMPLING_FREQUENCY 16000
00065 
00066 
00067 //Used for debugging purposes
00068 //#define NOTVERB
00069 #define BREAKPOINT cerr << "Bis hier" << endl;
00070 #ifndef NOTVERB
00071 #define PRINT(X) cerr << (#X) << ": " << (X) << endl;
00072 #endif
00073 #ifdef NOTVERB
00074 #define PRINT(X) ;
00075 #endif
00076 
00077 typedef dsp::vector< short > t_Signal;
00078 
00079 
00080 class OLA_Unit;
00081 
00085 class Phone {
00086 public:
00087         string tkey;
00088         long start, end;
00089         double intensity;
00090         double duration;
00091         double pitch;
00092         OLA_Unit * parent;
00093         Phone(OLA_Unit * __parent, string __tkey, long __start, long __end) : tkey(__tkey), start(__start), end(__end), parent(__parent) {}
00094         long getStart() { return start; }
00095         long getEnd() { return end; }
00096         long getLength() { return end - start; }
00097         double getNewDuration() { return duration; }
00098         double getNewPitch() { return pitch; }
00099 };
00100 
00101 
00102 
00107 class OLA_Unit : public ConmanUnit {
00108  public:
00109   double start_time;
00110   double end_time;
00111   long index; // iteration index used for manipulation
00112   SampledSignal<short> signal;
00113   Pitchmarks pitchmarks;
00114 //  vector<Phone> phones;
00115   Pitchmarks pitchContour;
00116 
00117   // Constructor for non-pause units
00118   OLA_Unit(BOSS::Config & __config, //ex-global
00119           MySQL_Handler * __database,    //ex-global
00120           xercesc::DOMNode * n,
00121           const string & t,     //tkey
00122           const string & i);    //inventory
00123   // Constructor for pause units
00124   OLA_Unit(BOSS::Config & __config, MySQL_Handler * __database,
00125           xercesc::DOMNode * n, const string & t); 
00126   OLA_Unit & operator=(const OLA_Unit & other);
00127   
00128   void manipulate(vector<Phone>& phones, PitchContour & contour);
00129   OLA_Frame<short> nextOLA_Frame();
00130   long nextPeriodLength();
00131   long getSignalLength();
00132   bool endReached();
00133   bool selfCheck();
00134   void loadPhoneticInformation(vector<Phone> & phones);
00135 
00136  protected:
00137 //  string getSentenceFileName(const string & inventory); // NOTE: delete if compiles and runs ok
00138   Phone getPhone(const DOM_UserData::Node_Type & type, const string & number, const string & inventory);
00139   void getPhones(const DOM_UserData::Node_Type & type, const string & number, const string & inventory, vector<Phone> & phones);
00140   
00141 };
00142 
00143  // end of group boss_ola
00145 
00146 #endif
00147 

Generated on Tue Dec 20 23:14:38 2005 for BOSS by doxygen 1.3.6