SMSTimeStretch.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 _SMSTimeStretch_
00023 #define _SMSTimeStretch_
00024 
00025 #include "Processing.hxx"
00026 #include "Frame.hxx"
00027 #include "InPort.hxx"
00028 #include "OutPort.hxx"
00029 #include "InControl.hxx"
00030 #include "SMSTimeStretchConfig.hxx"
00031 #include "SpectrumInterpolator.hxx"
00032 #include "SpectralPeakArrayInterpolator.hxx"
00033 
00034 // FIXME
00035 // #include "FrameInterpolator.hxx"
00036 
00037 namespace CLAM{
00038 
00044         class SMSTimeStretch: public Processing
00045         {
00046 
00047         //TODO introduce interpolation of spectral shapes, before that, interpolations may be extracted to external Processing's (this comment is also in doxygen class description)
00048                 const char *GetClassName() const {return "SMSTimeStretch";}
00049 
00050                 InPort<SpectralPeakArray> mInPeaks;
00051                 OutPort<SpectralPeakArray> mOutPeaks;
00052                 InPort<Fundamental> mInFund;
00053                 OutPort<Fundamental> mOutFund;
00054                 InPort<Spectrum> mInSpectrum;
00055                 OutPort<Spectrum> mOutSpectrum;
00056 
00057 
00058         public:
00059                 SMSTimeStretch()
00060                         :
00061                         mInPeaks("In SpectralPeaks", this),
00062                         mOutPeaks("Out SpectralPeaks", this),
00063                         mInFund("In Fundamental", this),
00064                         mOutFund("Out Fundamental", this),
00065                         mInSpectrum("In Spectrum", this),
00066                         mOutSpectrum("Out Spectrum", this)
00067                 {
00068                         Configure( mConfig );
00069                 }
00070 
00071                 ~SMSTimeStretch() {}
00072 
00073                 bool Do()
00074                 {
00075                         bool result = Do(mInPeaks.GetData(), 
00076                                          mInFund.GetData(), 
00077                                          mInSpectrum.GetData(), 
00078                                          mOutPeaks.GetData(), 
00079                                          mOutFund.GetData(),
00080                                          mOutSpectrum.GetData() 
00081                                          );
00082 
00083                         mInPeaks.Consume(); 
00084                         mInFund.Consume(); 
00085                         mInSpectrum.Consume(); 
00086                         mOutPeaks.Produce(); 
00087                         mOutFund.Produce();
00088                         mOutSpectrum.Produce();
00089 
00090                         return result;
00091                 }
00092 
00093                 bool Do(const Frame& in, Frame& out);
00094 
00095                 bool Do(const SpectralPeakArray& inPeaks,
00096                         const Fundamental& inFund,
00097                         const Spectrum& inSpectrum,
00098                         SpectralPeakArray& outPeaks,
00099                         Fundamental& outFund,
00100                         Spectrum& outSpectrum
00101                         );
00102 
00103 
00104 //FIXME
00105                 bool ConcreteStart();
00106                 bool ConcreteStop();
00107 
00108 //              bool CanProcessInplace() {return false;}
00109 //              bool IsLastFrame();
00110 //              
00111 //              Frame& GetCurrentFrame(Segment& out);
00112 //              const Frame& GetCurrentFrame(const Segment& in);
00113 //              
00114 
00115 //              FloatInControl mFactor;
00116 
00117                 typedef SMSTimeStretchConfig Config;
00118 
00119                 const ProcessingConfig & GetConfig() const
00120                 {
00121                         return mConfig;
00122                 }
00123 
00124         protected:
00125                 bool ConcreteConfigure(const ProcessingConfig& config);
00126 
00127         private:
00128                 Config mConfig;
00129 
00130         protected:
00131 //              bool HaveFinished();
00132 //              void UpdateTimeAndIndex(const Segment& in);
00133                 
00134                 TTime mSynthesisTime; 
00135                 TTime mAnalysisTime;
00136                 TIndex mnSynthesisFrames; 
00137                 
00138                 Frame mLeftFrame;
00139 
00141 //              FrameInterpolator mFrameInterpolator; // FIXME
00142                 SpectrumInterpolator mSpectrumInterpolator;
00143                 SpectralPeakArrayInterpolator mPeaksInterpolator;
00144         };
00145 };//namespace CLAM
00146 
00147 #endif // _SMSTimeStretch_
Generated by  doxygen 1.6.3