00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00068
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;
00112 SampledSignal<short> signal;
00113 Pitchmarks pitchmarks;
00114
00115 Pitchmarks pitchContour;
00116
00117
00118 OLA_Unit(BOSS::Config & __config,
00119 MySQL_Handler * __database,
00120 xercesc::DOMNode * n,
00121 const string & t,
00122 const string & i);
00123
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
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
00145
00146 #endif
00147