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