SpectralShapeShift.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 
00023 #ifndef _SpectralShapeShift_
00024 #define _SpectralShapeShift_
00025 
00026 #include "SpectralEnvelopeExtract.hxx"
00027 #include "SpectralEnvelopeApply.hxx"
00028 #include "Frame.hxx"
00029 #include "FDCombFilter.hxx"
00030 #include "InPort.hxx"
00031 #include "OutPort.hxx"
00032 #include "InControl.hxx"
00033 #include "FrameTransformation.hxx"
00034 #include "FrameTransformationConfig.hxx"
00035 #include "SegmentTransformationConfig.hxx"
00036 #include "SpectralPeakDetect.hxx"
00037 
00038 namespace CLAM{
00039 
00040 
00045         class SpectralShapeShift: public FrameTransformationTmpl<Spectrum>
00046         {
00047                 
00048                 const char *GetClassName() const {return "SpectralShapeShift";}
00049 
00050                 InPort<Spectrum> mIn;
00051                 OutPort<Spectrum> mOut;
00052 
00053                 FloatInControl mSteps;
00054         public:
00055 
00056                 SpectralShapeShift() 
00057                         : 
00058                         mIn( "InSpectrum", this),
00059                         mOut( "OutSpectrum", this),
00060                         mSteps("Shift Steps", this)
00061                 {
00062                         Configure( SegmentTransformationConfig() );
00063                         mSpectralRange=22050;   //default
00064                         mSpectralPeaks.AddAll();
00065                         mSpectralPeaks.UpdateData();
00066                         mSpectralPeaks.SetScale(EScale::eLog);
00067                         mSpectralEnvelope.AddAll();
00068                         mSpectralEnvelope.UpdateData();
00069                         
00070                         SpectralPeakDetectConfig cfg;
00071                         cfg.SetMagThreshold(-80.f);
00072                         cfg.SetMaxPeaks(200);   
00073                         cfg.SetMaxFreq(15000.f);
00074                         mSpectralPeakDetect.Configure(cfg);
00075                         
00076                         SpectralEnvelopeExtractConfig envCfg;
00077                         envCfg.SetMaxPeaks(1000);
00078                         mSpectralEnvelopeExtract.Configure(envCfg);
00079                 }
00080 
00081                 ~SpectralShapeShift() {}
00082 
00083                 bool Do(const Frame& in, Frame& out)
00084                 {
00085                         return Do(in.GetSpectrum(), 
00086                                 out.GetSpectrum());
00087                 }
00088         
00089                 bool Do(const Spectrum& inpeaks,Spectrum& out);
00090 
00091                 bool Do()
00092                 {
00093                         bool result = Do(mIn.GetData(), mOut.GetData());
00094                         mIn.Consume();
00095                         mOut.Produce();
00096                         return result;  
00097                 }
00098 
00099         private:
00100                 SpectralEnvelopeExtract mSpectralEnvelopeExtract;
00101                 SpectralEnvelopeApply mSpectralEnvelopeApply;
00102                 SpectralPeakDetect mSpectralPeakDetect;
00103                 Spectrum mSpectralEnvelope;
00104                 Spectrum mLogSpectrum;
00105                 SpectralPeakArray mSpectralPeaks;
00106                 TSize mSpectralRange;
00107         };              
00108 }       //namespace CLAM
00109 
00110 #endif // _SpectralShapeShift_
00111 
Generated by  doxygen 1.6.3