WoMax Documentation OMax Logo

Oracle_label.cpp

Go to the documentation of this file.
00001 /*-------------------------------------
00002  * Oracle_label.cpp
00003  * Created on 09/03/09 by BenCello
00004  *-------------------------------------*/
00005 
00007 
00008 #include "Oracle_label.hpp"
00009 
00010 /* Generic Label functions */
00011 
00012 O_label::O_label()
00013 {
00015         statenb = 0;
00016         bufferef = 0;
00017         duration = 0;
00018         section = 0;
00019         phrase = 0;
00020 }
00021 
00023 O_label::O_label(int statenbin, int bufferefin, int durationin, int phrasein, int sectionin)
00024 {
00025         statenb = statenbin;
00026         bufferef = bufferefin;
00027         duration = durationin;
00028         phrase = phrasein;
00029         section = sectionin;
00030 }
00031 
00032 O_label::O_label(const O_label & labelin)
00033 {
00034         statenb = labelin.statenb;
00035         bufferef = labelin.bufferef;
00036         duration = labelin.duration;
00037         section = labelin.section;
00038         phrase = labelin.phrase;
00039 }
00040 
00041 int O_label::get_statenb()
00042 {
00043         return statenb;
00044 }
00045 
00046 void O_label::set_statenb(int statnbin)
00047 {
00048         statenb = statnbin;
00049 }
00050 
00051 int O_label::get_bufferef()
00052 {
00053         return bufferef;
00054 }
00055 
00056 void O_label::set_bufferef(int bufferefin)
00057 {
00058         bufferef = bufferefin;
00059 }
00060 
00061 int O_label::get_duration()
00062 {
00063         return duration;
00064 }
00065 
00066 void O_label::set_duration(int durationin)
00067 {
00068         duration = durationin;
00069 }
00070 
00071 int O_label::get_phrase()
00072 {
00073         return phrase;
00074 }
00075 
00076 void O_label::set_phrase(int phrasein)
00077 {
00078         phrase = phrasein;
00079 }
00080 
00081 int O_label::get_section()
00082 {
00083         return section;
00084 }
00085 
00086 void O_label::set_section(int sectionin)
00087 {
00088         section = sectionin;
00089 }
00090 
00091 /* char functions */
00092 
00095 O_char::O_char() : O_label()
00096 {
00097         letter = ' ';
00098 }
00099 
00101 O_char::O_char(char charin) : O_label()
00102 {
00104         duration = 1;
00105         letter = charin;
00106 }
00107 
00109 O_char::O_char(const O_char & ocharin) : O_label(ocharin)
00110 {
00111         letter = ocharin.letter;
00112 }
00113 
00114 char O_char::get_letter()
00115 {
00116         return letter;
00117 }
00118 
00119 bool O_char::operator== (const O_char & other) const
00120 {
00122         return(letter == other.letter);
00123 }
00124 
00125 ostream & operator<< (ostream & out, const O_char & charin)
00126 {
00127         out<<charin.letter;
00128         return(out);
00129 }
00130 
00131 /* MIDI_mono functions */
00132 
00135 O_MIDI_mono::O_MIDI_mono() : O_label()
00136 {
00137         pitch = 60;
00138         velocity = 0;
00139         channel = 128;
00140 }
00141 
00144 O_MIDI_mono::O_MIDI_mono(int pitchin, int velocityin, int statenbin, int bufferefin, int durationin, int phrasein, int sectionin) : O_label(statenbin, bufferefin, durationin, phrasein, sectionin)
00145 {
00146         pitch = pitchin;
00147         velocity = velocityin;
00148 }
00149 
00150 O_MIDI_mono::O_MIDI_mono(const O_MIDI_mono & midin) : O_label(midin)
00151 {
00152         pitch = midin.pitch;
00153         velocity = midin.velocity;
00154         channel = midin.channel;
00155 }
00156 
00157 int O_MIDI_mono::get_pitch()
00158 {
00159         return pitch;
00160 }
00161 
00162 void O_MIDI_mono::set_pitch(int pitchin)
00163 {
00164         pitch = pitchin;
00165 }
00166 
00167 int O_MIDI_mono::get_velocity()
00168 {
00169         return velocity;
00170 }
00171 
00172 void O_MIDI_mono::set_velocity(int velocityin)
00173 {
00174         velocity = velocityin;
00175 }
00176 
00177 // Operators Overload
00178 bool O_MIDI_mono::operator== (const O_MIDI_mono & other) const
00179 {
00181         return((pitch % 12) == (other.pitch % 12));
00182 }
00183 
00186 ostream & operator<< (ostream & out, const O_MIDI_mono & midin)
00187 {
00188         out<<midin.pitch<<" "<<midin.velocity<<" ";
00189         out<<midin.phrase<<" "<<midin.bufferef<<endl;
00190         return(out);
00191 }
00192 
00193 /* spectral functions */
00194 
00197 O_spectral::O_spectral() : O_label()
00198 {
00199         pitch = 60;
00200         energy = 0.0;
00201 }
00202 
00205 O_spectral::O_spectral(int pitchin, list<float> & coeffin, int statenbin, int bufferefin, int durationin, int phrasein, int sectionin) : O_label(statenbin, bufferefin, durationin, phrasein, sectionin)
00206 {
00207         pitch = pitchin;
00208         if (!coeffin.empty())
00209         {
00210                 energy = coeffin.front();
00211                 coeffs = coeffin;
00212         }
00213 }
00214 
00215 O_spectral::O_spectral(const O_spectral & spectralin) : O_label (spectralin)
00216 {
00217         pitch = spectralin.pitch;
00218         energy = spectralin.pitch;
00219         coeffs = spectralin.coeffs;
00220 }
00221 
00222 int O_spectral::get_pitch()
00223 {
00224         return pitch;
00225 }
00226 
00227 void O_spectral::set_pitch(int pitchin)
00228 {
00229         pitch = pitchin;
00230 }
00231 
00232 float O_spectral::get_energy()
00233 {
00234         return energy;
00235 }
00236 
00237 void O_spectral::set_energy(float energin)
00238 {
00239         energy = energin;
00240 }
00241 
00242 void O_spectral::set_energy(list<float> & coeffin)
00243 {
00244         energy = coeffin.front();
00245 }
00246 
00247 list<float>
00248 O_spectral::get_coeffs()
00249 {
00250         return coeffs;
00251 }
00252 
00253 void O_spectral::set_coeffs(list<float> & coeffin)
00254 {
00255         if(!coeffin.empty())
00256         {
00257                 energy = coeffin.front();
00258                 coeffs = coeffin;
00259         }
00260 }
00261 
00262 // Operator Overload
00263 bool O_spectral::operator== (const O_spectral & other) const
00264 {
00267         bool out = true;
00268         if (coeffs.size()!=other.coeffs.size())
00269                 return false;
00270         list<float>::const_iterator it = ++coeffs.begin();
00271         list<float>::const_iterator otherit = ++other.coeffs.begin();
00272         while (out == true && it!=coeffs.end())
00273         {
00274                 out = (*it == *otherit);
00275                 it++;
00276                 otherit++;
00277         }
00278         return out;
00279 }
00280 
00281 ostream & operator<< (ostream & out, const O_spectral & spectralin)
00282 {
00283         out<<spectralin.pitch<<" : ";
00284         list<float>::const_iterator it;
00285         for (it = spectralin.coeffs.begin(); it!= spectralin.coeffs.end(); it++)
00286                 out<<(*it)<<" ";
00287         out<<" : "<<spectralin.phrase<<" "<<spectralin.bufferef<<endl;
00288         return(out);
00289 }

Generated on 16 Mar 2010 for Benjamin Lévy by  doxygen 1.6.1