ERB_Space_Gen.cxx

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 //Implemented from Slaney's Auditory Toolbox (http://rvl4.ecn.purdue.edu/~malcolm/interval/1998-010/)
00024 
00025 
00026 #include "ERB_Space_Gen.hxx"
00027 #include "CLAM_Math.hxx"
00028 
00029 namespace CLAM
00030 {
00031 
00032 ERB_SpaceGen::ERB_SpaceGen()
00033 {
00034         Configure(ERB_SpaceGenConfig());
00035 }
00036 
00037 ERB_SpaceGen::ERB_SpaceGen(ERB_SpaceGenConfig& c)
00038 {
00039         Configure(c);
00040 }
00041 
00042 
00043 ERB_SpaceGen::~ERB_SpaceGen() {}
00044 
00045 bool ERB_SpaceGen::ConcreteConfigure(const ProcessingConfig& c)
00046 {
00047         CopyAsConcreteConfig( mConfig, c );
00048 
00049         mNumFilter=mConfig.GetNumFilter();
00050         mLowFreq=(TData)mConfig.GetLowFreq();
00051         mHighFreq=(TData)mConfig.GetHighFreq();
00052         
00053         return true;
00054 }
00055 
00056 bool ERB_SpaceGen::Do(Array<double>& mERBFreqs)
00057 {
00058         int i;
00059         
00060         //Change the following three parameters if you wish to use a different
00061         //ERB scale.  Must change in MakeERBCoeffs too.
00062         double earQ = 9.26449;                          // Glasberg and Moore Parameters
00063         double minBW = 24.7;
00064 
00065         // All of the followFreqing expressions are derived in Apple TR #35, "An
00066         // Efficient Implementation of the Patterson-Holdsworth Cochlear
00067         // Filter Bank."  See pages 33-34.
00068         for( i=0; i<mNumFilter; i++)
00069         {
00070                 mERBFreqs[i]=-(earQ*minBW) 
00071                         + std::exp((i+1)*(-std::log(mHighFreq + earQ*minBW) + std::log(mLowFreq + earQ*minBW))/mNumFilter) * (mHighFreq + earQ*minBW);
00072         }
00073 
00074         return true;
00075 }
00076 
00077 } // namespace CLAM
00078 
Generated by  doxygen 1.6.3