CLAM-Development
1.1
|
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 _SpectralPeakArray_Interpolator_ 00023 #define _SpectralPeakArray_Interpolator_ 00024 00025 #include "Processing.hxx" 00026 #include "DynamicType.hxx" 00027 #include "InPort.hxx" 00028 #include "OutPort.hxx" 00029 #include "SpectralPeakArray.hxx" 00030 #include "InControl.hxx" 00031 #include "Spectrum.hxx" 00032 00033 namespace CLAM { 00034 00035 00036 class PeaksInterpConfig: public ProcessingConfig 00037 { 00038 public: 00039 DYNAMIC_TYPE_USING_INTERFACE (PeaksInterpConfig, 5,ProcessingConfig); 00040 DYN_ATTRIBUTE(0, public, TData, MagInterpolationFactor); 00041 DYN_ATTRIBUTE(1, public, TData, FreqInterpolationFactor); 00042 DYN_ATTRIBUTE(2, public, TData, PitchInterpolationFactor); 00043 DYN_ATTRIBUTE(3, public, bool, Harmonic); 00044 DYN_ATTRIBUTE(4,public, bool, UseSpectralShape); 00045 protected: 00046 void DefaultInit(); 00047 void DefaultValues(); 00048 00049 }; 00050 00054 class SpectralPeakArrayInterpolator: public Processing { 00055 00056 typedef InControlTmpl<SpectralPeakArrayInterpolator> SpectralPeakArrayInterpolatorCtl; 00057 00058 PeaksInterpConfig mConfig; 00059 00060 const char *GetClassName() const {return "SpectralPeakArrayInterpolator";} 00061 00062 00066 bool ConcreteConfigure(const ProcessingConfig&); 00067 00068 public: 00069 SpectralPeakArrayInterpolator(); 00070 00071 SpectralPeakArrayInterpolator(const PeaksInterpConfig &c); 00072 00073 ~SpectralPeakArrayInterpolator() {}; 00074 00075 const ProcessingConfig &GetConfig() const { return mConfig;} 00076 00077 bool Do(void); 00078 00079 bool Do(const SpectralPeakArray& in1, const SpectralPeakArray& in2, SpectralPeakArray& out); 00080 bool Do(const SpectralPeakArray& in1, const SpectralPeakArray& in2,const Spectrum& spectralShape, SpectralPeakArray& out); 00081 00083 SpectralPeakArrayInterpolatorCtl mMagInterpolationFactorCtl; 00084 SpectralPeakArrayInterpolatorCtl mFreqInterpolationFactorCtl; 00085 SpectralPeakArrayInterpolatorCtl mPitchInterpolationFactorCtl; 00086 00089 SpectralPeakArrayInterpolatorCtl mPitch1Ctl; 00090 SpectralPeakArrayInterpolatorCtl mPitch2Ctl; 00091 00093 SpectralPeakArrayInterpolatorCtl mIsHarmonicCtl; 00094 00096 InPort<SpectralPeakArray> mIn1; 00097 InPort<SpectralPeakArray> mIn2; 00098 OutPort<SpectralPeakArray> mOut; 00099 00100 Spectrum* mpSpectralShape; 00101 void AttachSpectralShape( Spectrum& spec ) { mpSpectralShape = &spec; } 00102 private: 00103 bool FindHarmonic(const IndexArray& indexArray,int index,int& lastPosition); 00104 00105 00106 }; 00107 00108 } 00109 00110 #endif // _SpectralPeakArray_Interpolator_ 00111