Mercurial > hg > aimc
comparison carfac/carfac_common.h @ 609:aefe2ca0674f
First version of a C++ implementation by Alex Brandmeyer
author | alexbrandmeyer |
---|---|
date | Mon, 13 May 2013 22:51:15 +0000 |
parents | |
children | 01986636257a |
comparison
equal
deleted
inserted
replaced
608:fc353426eaad | 609:aefe2ca0674f |
---|---|
1 // | |
2 // carfac_common.h | |
3 // CARFAC Open Source C++ Library | |
4 // | |
5 // Created by Alex Brandmeyer on 5/10/13. | |
6 // | |
7 // This C++ file is part of an implementation of Lyon's cochlear model: | |
8 // "Cascade of Asymmetric Resonators with Fast-Acting Compression" | |
9 // to supplement Lyon's upcoming book "Human and Machine Hearing" | |
10 // | |
11 // Licensed under the Apache License, Version 2.0 (the "License"); | |
12 // you may not use this file except in compliance with the License. | |
13 // You may obtain a copy of the License at | |
14 // | |
15 // http://www.apache.org/licenses/LICENSE-2.0 | |
16 // | |
17 // Unless required by applicable law or agreed to in writing, software | |
18 // distributed under the License is distributed on an "AS IS" BASIS, | |
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
20 // See the License for the specific language governing permissions and | |
21 // limitations under the License. | |
22 // | |
23 // ***************************************************************************** | |
24 // carfac_common.h | |
25 // ***************************************************************************** | |
26 // This file contains the base level definitions and includes used within the | |
27 // CARFAC C++ library. It also defines some low level functions which are used | |
28 // during the calculation of the various coefficient sets required by the model. | |
29 // | |
30 // The current implementation of the library is dependent on the use of the | |
31 // Eigen C++ library for linear algebra. Specifically, Eigen Arrays are used | |
32 // extensively for coefficient wise operations during both the design and run | |
33 // stages of the model. | |
34 // | |
35 // The 'FPType' typedef is specified in this file in order to enable quick | |
36 // switching between precision levels (i.e. float vs. double) throughout the | |
37 // library. The remainder of the code uses this type for specifying floating | |
38 // point scalars. | |
39 // | |
40 // Two additional typedefs are defined for one and two dimensional arrays: | |
41 // FloatArray and FloatArray2d. These in turn make use of FPType so that the | |
42 // precision level across floating point data is consistent. | |
43 // | |
44 // The functions 'ERBHz' and 'CARFACDetect' are defined here, and are used | |
45 // during the design stage of a CARFAC model. | |
46 | |
47 #ifndef CARFAC_Open_Source_C__Library_CARFACCommon_h | |
48 #define CARFAC_Open_Source_C__Library_CARFACCommon_h | |
49 | |
50 #include <iostream> //Used for debugging output, could go in final version | |
51 #include <math.h> //Used during coefficient calculations | |
52 #include <Eigen/Dense> //Used for 1d and 2d floating point arrays | |
53 using namespace Eigen; | |
54 | |
55 #define PI 3.141592 | |
56 typedef float FPType; //Used to enable easy switching in precision level | |
57 | |
58 //typedefs for Eigen floating point arrays | |
59 typedef Eigen::Array<FPType,Dynamic,1> FloatArray; //1d floating point array | |
60 typedef Eigen::Array<FPType,Dynamic,Dynamic> FloatArray2d; //2d fpoint array | |
61 | |
62 // Function: ERBHz | |
63 // Auditory filter nominal Equivalent Rectangular Bandwidth | |
64 // Ref: Glasberg and Moore: Hearing Research, 47 (1990), 103-138 | |
65 FPType ERBHz(FPType cf_hz, FPType erb_break_freq, FPType erb_q); | |
66 | |
67 // Function CARFACDetect | |
68 // TODO explain a bit more | |
69 FPType CARFACDetect (FPType x); | |
70 FloatArray CARFACDetect (FloatArray x); | |
71 #endif |