FDFilterGen.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 _SpectralFilterGen_
00024 #define _SpectralFilterGen_
00025 
00026 #include "Processing.hxx"
00027 #include "ProcessingData.hxx"
00028 #include "DataTypes.hxx"
00029 #include "Audio.hxx"
00030 #include "OutPort.hxx"
00031 #include "Spectrum.hxx"
00032 #include "Enum.hxx"
00033 
00034 namespace CLAM {
00035 
00036 class EFDFilterGenControls : public Enum
00037 {
00038 public:
00039         
00040         EFDFilterGenControls() : Enum(ValueTable(), gain) { }
00041         EFDFilterGenControls(tValue v) : Enum(ValueTable(), v) { }
00042         EFDFilterGenControls(std::string s) : Enum(ValueTable(), s) { }
00043         ~EFDFilterGenControls() { };
00044 
00045         Component * Species() const 
00046         { 
00047                 return new EFDFilterGenControls;
00048         }
00049 
00050         enum 
00051         {
00052                 gain=0,
00053                 highcutoff,
00054                 lowcutoff,
00055                 passbandslope,
00056                 stopbandslope
00057         } tEnum;
00058 
00059         static tEnumValue * ValueTable()
00060         {
00061                 static tEnumValue sEnumValues[] =
00062                 {
00063                         { gain, "gain" },
00064                         { highcutoff, "highcutoff" },
00065                         { lowcutoff, "lowcutoff" },
00066                         { passbandslope, "passbandslope" },
00067                         { stopbandslope, "stopbandslope" },
00068                         { 0, NULL }
00069                 };
00070                 return sEnumValues;
00071         }
00072 };
00073 
00075 class EFDFilterType : public Enum
00076 {
00077 public:
00078         
00079         EFDFilterType() : Enum(ValueTable(), eLowPass) {}
00080         EFDFilterType(tValue v) : Enum(ValueTable(), v) {};
00081         EFDFilterType(std::string s) : Enum(ValueTable(), s) {};
00082 
00083         enum {
00084                 eLowPass,
00085                 eHighPass,
00086                 eBandPass,
00087                 eStopBand
00088         };
00089 
00090         virtual Component* Species() const
00091         {
00092                 // TODO: This is a xapusa. I want a default constructor!
00093                 return (Component*) new EFDFilterType(eLowPass);
00094         };
00095         static tEnumValue * ValueTable()
00096         {
00097                 static tEnumValue sEnumValues[] = {
00098                         {eLowPass,"Low-pass"},
00099                         {eHighPass,"High-pass"},
00100                         {eBandPass,"Band-pass"},
00101                         {eStopBand,"Stop-Band"},
00102                         {0,NULL}
00103                 };
00104                 return sEnumValues;
00105         }
00106 };
00107 
00108 
00110 class FDFilterGenConfig: public ProcessingConfig 
00111 {
00112 public:
00113         DYNAMIC_TYPE_USING_INTERFACE (FDFilterGenConfig, 7, ProcessingConfig);
00114         DYN_ATTRIBUTE (0, public, EFDFilterType, Type);
00115         DYN_ATTRIBUTE (1, public, TData, SpectralRange);
00116         DYN_ATTRIBUTE (2, public, TData, Gain);
00117         DYN_ATTRIBUTE (3, public, TData, HighCutOff);
00118         DYN_ATTRIBUTE (4, public, TData, LowCutOff);
00119         DYN_ATTRIBUTE (5, public, TData, PassBandSlope);
00120         DYN_ATTRIBUTE (6, public, TData, StopBandSlope);
00121 protected:
00122         void DefaultInit(void);
00123 };
00124 
00126 class FDFilterGen: public Processing
00127 {
00128 private:
00129         typedef FDFilterGenConfig Config;
00130 
00131 public:
00132         OutPort<Spectrum> Output;
00133         
00134         FloatInControl Gain;
00135         FloatInControl HighCutOff;
00136         FloatInControl LowCutOff;
00137         FloatInControl PassBandSlope;
00138         FloatInControl StopBandSlope;
00139         
00140 private:
00141         TData SpectralRange;
00142         EFDFilterType Type;
00143         
00144         Config mConfig;
00145         
00146         bool mControlChanged;
00147 protected:
00148         
00149         // Control change callback function
00150         void UpdateControlChangedFlag(TControlData);
00151 
00152                 
00153 public:
00154         
00158         FDFilterGen(const Config &c = Config());
00159         
00160 
00161         virtual ~FDFilterGen()
00162         {
00163         }
00167         bool Do();
00168         
00177         bool Do(Spectrum &out);
00178         
00180         const ProcessingConfig &GetConfig() const { return mConfig; };
00181                 
00182 private:
00183         
00184         const char *GetClassName() const {return "FDFilterGen";}
00185         
00187         bool ConcreteConfigure(const ProcessingConfig& c);
00188 
00190         void SetFilterPoint(
00191                         Spectrum& out,
00192                         TIndex pos,
00193                         TData freq,
00194                         TData mag,
00195                         TData phase=0
00196                 );
00197         
00198 };
00199 
00200 } //namespace CLAM
00201 
00202 
00203 #endif // _FFT_
00204 
Generated by  doxygen 1.6.3