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 _SpectralPeakDetect_ 00023 #define _SpectralPeakDetect_ 00024 00025 #include "Processing.hxx" 00026 #include "InPort.hxx" 00027 #include "OutPort.hxx" 00028 #include "SpectralPeakDetectConfig.hxx" 00029 #include "Spectrum.hxx" 00030 00031 namespace CLAM 00032 { 00033 00034 class SpectralPeakArray; 00035 class Storage; 00036 class ProcessingConfig; 00037 00048 class SpectralPeakDetect: public Processing { 00049 00050 protected: // attributes 00051 SpectralPeakDetectConfig mConfig; 00052 00053 InPort< Spectrum > mInput; 00054 OutPort< SpectralPeakArray > mOutput; 00055 00056 protected: // methods 00060 const char *GetClassName() const {return "SpectralPeakDetect";} 00061 00067 bool ConcreteConfigure(const ProcessingConfig&); 00068 00069 public: 00071 SpectralPeakDetect(); 00075 SpectralPeakDetect(const SpectralPeakDetectConfig &c); 00076 00078 virtual ~SpectralPeakDetect(); 00079 00080 00084 const ProcessingConfig &GetConfig() const { return mConfig;} 00085 00087 bool Do(void); 00088 00094 bool Do(const Spectrum& input, SpectralPeakArray& out); 00095 00102 bool SetPrototypes(Spectrum& inputs,const SpectralPeakArray& out); 00103 00104 bool SetPrototypes(); 00105 00106 bool UnsetPrototypes(); 00107 00108 bool MayDisableExecution() const {return true;} 00109 00110 private: 00112 inline void Detect(Spectrum& inputs, Spectrum& out); 00113 00114 bool CheckInputType(const Spectrum &in); 00115 bool CheckOutputType(const SpectralPeakArray &out); 00116 00117 Spectrum mTmpLinearInSpectrum; 00118 }; 00119 00120 } //namespace CLAM 00121 00122 #endif // _SpectralPeak_Detect_ 00123