annotate src/Support/ERBTools.h @ 16:2a5354042241

-Updated the Slaney IIR gammatone to use a cascase of four second-order filters as per the implementtion in Slaney's auditory toolbox. This is more numerically stable at high sample rates and low centre frequencies.
author tomwalters
date Sat, 20 Feb 2010 17:56:40 +0000
parents b4cafba48e9d
children 491b1b1d1dc5
rev   line source
tomwalters@0 1 // Copyright 2006-2010, Thomas Walters
tomwalters@0 2 //
tomwalters@0 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@0 4 // http://www.acousticscale.org/AIMC
tomwalters@0 5 //
tomwalters@0 6 // This program is free software: you can redistribute it and/or modify
tomwalters@0 7 // it under the terms of the GNU General Public License as published by
tomwalters@0 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@0 9 // (at your option) any later version.
tomwalters@0 10 //
tomwalters@0 11 // This program is distributed in the hope that it will be useful,
tomwalters@0 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@0 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@0 14 // GNU General Public License for more details.
tomwalters@0 15 //
tomwalters@0 16 // You should have received a copy of the GNU General Public License
tomwalters@0 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@0 18
tomwalters@0 19 /*! \file
tomwalters@5 20 * \brief ERB calculations
tomwalters@0 21 */
tomwalters@0 22
tomwalters@0 23 /*! \author: Thomas Walters <tom@acousticscale.org>
tomwalters@0 24 * \date 2010/01/23
tomwalters@0 25 * \version \$Id: ERBTools.h 1 2010-02-02 11:04:50Z tcw $
tomwalters@0 26 */
tomwalters@0 27
tomwalters@11 28 #ifndef AIMC_SUPPORT_ERBTOOLS_H_
tomwalters@11 29 #define AIMC_SUPPORT_ERBTOOLS_H_
tomwalters@0 30
tomwalters@15 31 #include <cmath>
tomwalters@0 32
tomwalters@0 33 namespace aimc {
tomwalters@0 34 class ERBTools {
tomwalters@0 35 public:
tomwalters@0 36 static float Freq2ERB(float freq) {
tomwalters@0 37 return 21.4f * log10(4.37f * freq / 1000.0f + 1.0f);
tomwalters@0 38 }
tomwalters@0 39
tomwalters@0 40 static float Freq2ERBw(float freq) {
tomwalters@0 41 return 24.7f * (4.37f * freq / 1000.0f + 1.0f);
tomwalters@0 42 }
tomwalters@5 43
tomwalters@5 44 static float ERB2Freq(float erb) {
tomwalters@5 45 return (pow(10, (erb / 21.4f)) - 1.0f) / 4.37f * 1000.0f;
tomwalters@5 46 }
tomwalters@0 47 };
tomwalters@0 48 }
tomwalters@0 49
tomwalters@11 50 #endif // AIMC_SUPPORT_ERBTOOLS_H_