SMSMorph.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef _SMSMorph_
00023 #define _SMSMorph_
00024 
00025 #include "SMSMorphConfig.hxx"
00026 
00027 #include "Processing.hxx"
00028 #include "Frame.hxx"
00029 #include "InPort.hxx"
00030 #include "OutPort.hxx"
00031 #include "InControl.hxx"
00032 #include "SpectrumInterpolator.hxx"
00033 #include "SpectralPeakArrayInterpolator.hxx"
00034 
00035 
00036 namespace CLAM{
00037 
00042         class SMSMorph: public Processing
00043         {
00044                 const char *GetClassName() const {return "SMSMorph";}
00045 
00046                 InPort<SpectralPeakArray> mInPeaks1;
00047                 InPort<Fundamental> mInFund1;
00048                 InPort<Spectrum> mInSpectrum1;
00049 
00050                 InPort<SpectralPeakArray> mInPeaks2;
00051                 InPort<Fundamental> mInFund2;
00052                 InPort<Spectrum> mInSpectrum2;
00053 
00054                 //TODO add many sources morph option? (with configurable amount)
00055 
00056                 OutPort<SpectralPeakArray> mOutPeaks;
00057                 OutPort<Fundamental> mOutFund;
00058                 OutPort<Spectrum> mOutSpectrum;
00059 
00063                 FloatInControl mInterpolationFactor; 
00064 
00065         public:
00066                 SMSMorph()
00067                         :
00068                         mInPeaks1("In SpectralPeaks 1", this),
00069                         mInFund1("In Fundamental 1", this),
00070                         mInSpectrum1("In Spectrum 1", this),
00071                 
00072                         mInPeaks2("In SpectralPeaks 2", this),
00073                         mInFund2("In Fundamental 2", this),
00074                         mInSpectrum2("In Spectrum 2", this),
00075                 
00076                         mOutPeaks("Out SpectralPeaks", this),
00077                         mOutFund("Out Fundamental", this),
00078                         mOutSpectrum("Out Spectrum", this),
00079 
00080                         mInterpolationFactor("Interpolation Factor", this)
00081                 {
00082                         Configure( mConfig );
00083                 }
00084 
00085                 ~SMSMorph() {}
00086 
00087                 bool Do()
00088                 {
00089                         bool result = Do(mInPeaks1.GetData(),
00090                                          mInFund1.GetData(),
00091                                          mInSpectrum1.GetData(),
00092                                          mInPeaks2.GetData(),
00093                                          mInFund2.GetData(),
00094                                          mInSpectrum2.GetData(),
00095                                          mOutPeaks.GetData(),
00096                                          mOutFund.GetData(),
00097                                          mOutSpectrum.GetData()
00098                                          );
00099 
00100                         mInPeaks1.Consume();
00101                         mInFund1.Consume();
00102                         mInSpectrum1.Consume();
00103 
00104                         mInPeaks2.Consume();
00105                         mInFund2.Consume();
00106                         mInSpectrum2.Consume();
00107 
00108                         mOutPeaks.Produce();
00109                         mOutFund.Produce();
00110                         mOutSpectrum.Produce();
00111 
00112                         return result;
00113                 }
00114 
00115                 bool Do(const SpectralPeakArray& inPeaks1,
00116                         const Fundamental& inFund1,
00117                         const Spectrum& inSpectrum1,
00118                         const SpectralPeakArray& inPeaks2,
00119                         const Fundamental& inFund2,
00120                         const Spectrum& inSpectrum2,
00121                         SpectralPeakArray& outPeaks,
00122                         Fundamental& outFund,
00123                         Spectrum& outSpectrum
00124                         );
00125 
00126                 //TODO - check if it's still useful
00127                 bool Do(const Frame& in1, const Frame& in2, Frame& out);
00128 
00129                 typedef SMSMorphConfig Config;
00130 
00131                 const ProcessingConfig& GetConfig() const
00132                 {
00133                         return mConfig;
00134                 }
00135 
00136         private:
00137                 Config mConfig;
00138 
00139         protected:
00140                 bool ConcreteConfigure(const ProcessingConfig& c);
00141 
00142 
00144                 SpectrumInterpolator mSpectrumInterpolator;
00145                 SpectralPeakArrayInterpolator mPeaksInterpolator;
00146 
00147         };              
00148 };//namespace CLAM
00149 
00150 #endif // _SMSMorph_
00151 
Generated by  doxygen 1.6.3