CLAM-Development  1.4.0
MelFilterBank.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef __MELFILTERBANK__
23 #define __MELFILTERBANK__
24 
25 #include "Processing.hxx"
26 #include "Spectrum.hxx"
27 #include "MelSpectrum.hxx"
28 #include "Array.hxx"
29 #include "InPort.hxx"
30 #include "OutPort.hxx"
31 
32 namespace CLAM
33 {
34 
36  {
37  public:
40  DYN_ATTRIBUTE( 0, public, TSize, SpectrumSize );
42  DYN_ATTRIBUTE( 1, public, TData, SpectralRange );
44  DYN_ATTRIBUTE( 2, public, TData, LowCutoff );
46  DYN_ATTRIBUTE( 3, public, TData, HighCutoff );
48  DYN_ATTRIBUTE( 4, public, TSize, NumBands );
50  DYN_ATTRIBUTE( 5, public, bool, UsePower );
51 
52  protected:
53  void DefaultInit();
54  };
55 
67  class MelFilterBank : public Processing
68  {
69  public:
70  MelFilterBank();
71 
73 
75 
76  bool Do();
77 
87  bool Do(const Spectrum& s, MelSpectrum& ms );
88 
89  const ProcessingConfig& GetConfig() const
90  {
91  return mConfig;
92  }
93 
94  virtual const char* GetClassName() const
95  {
96  return "MelFilterBank";
97  }
98 
99  protected:
100 
101  virtual bool ConcreteConfigure( const ProcessingConfig& cfg );
102 
103  protected:
104 
111  TData Mel( TData linFreq );
112 
113  void InitializeTables();
114 
115  private:
116 
117  MelFilterBankConfig mConfig;
118  Array<TIndex> mMelBand;
119  DataArray mFilterWeights;
120  TIndex mLowIdx;
121  TIndex mHighIdx;
122  InPort<Spectrum> mIn;
124  };
125 }
126 
127 
128 #endif // MelFilterBank.hxx
129