jamie@141
|
1 /*
|
jamie@141
|
2 * Copyright (C) 2012 Jamie Bullock
|
jamie@57
|
3 *
|
jamie@141
|
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
|
jamie@141
|
5 * of this software and associated documentation files (the "Software"), to
|
jamie@141
|
6 * deal in the Software without restriction, including without limitation the
|
jamie@141
|
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
jamie@141
|
8 * sell copies of the Software, and to permit persons to whom the Software is
|
jamie@141
|
9 * furnished to do so, subject to the following conditions:
|
jamie@57
|
10 *
|
jamie@141
|
11 * The above copyright notice and this permission notice shall be included in
|
jamie@141
|
12 * all copies or substantial portions of the Software.
|
jamie@57
|
13 *
|
jamie@141
|
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
jamie@141
|
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
jamie@141
|
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
jamie@141
|
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
jamie@141
|
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
jamie@141
|
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
jamie@141
|
20 * IN THE SOFTWARE.
|
jamie@141
|
21 *
|
jamie@57
|
22 */
|
jamie@57
|
23
|
jamie@57
|
24 /** \file xtract_macros_private.h: defines useful internal macros */
|
jamie@57
|
25
|
jamie@57
|
26 #ifndef XTRACT_MACROS_PRIVATE_H
|
jamie@57
|
27 #define XTRACT_MACROS_PRIVATE_H
|
jamie@57
|
28
|
jamie@57
|
29 #include <stdio.h>
|
jamie@57
|
30
|
jamie@57
|
31 #define XTRACT_SQ(a) ((a) * (a))
|
jamie@57
|
32 #define XTRACT_MIN(a, b) ((a) < (b) ? (a) : (b))
|
jamie@57
|
33 #define XTRACT_MAX(a, b) ((a) > (b) ? (a) : (b))
|
jamie@57
|
34 #define XTRACT_VERY_SMALL_NUMBER 2e-42
|
jamie@57
|
35 #define XTRACT_LOG_LIMIT XTRACT_VERY_SMALL_NUMBER
|
jamie@73
|
36 #define XTRACT_LOG_LIMIT_DB -96.0
|
jamie@73
|
37 #define XTRACT_DB_SCALE_OFFSET 96.0
|
jamie@57
|
38 #define XTRACT_VERY_BIG_NUMBER 2e42
|
jamie@73
|
39 #define XTRACT_SR_UPPER_LIMIT 192000.0
|
jamie@73
|
40 #define XTRACT_SR_LOWER_LIMIT 22050.0
|
jamie@73
|
41 #define XTRACT_SR_DEFAULT 44100.0
|
jamie@73
|
42 #define XTRACT_FUNDAMENTAL_DEFAULT 440.0
|
jamie@57
|
43 #define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2
|
jamie@57
|
44 #define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N
|
jamie@120
|
45 #define XTRACT_GET_MAX max = result[m] > max ? result[m] : max
|
jamie@120
|
46 #define XTRACT_SET_FREQUENCY result[M + m] = n * q
|
jamie@59
|
47 #define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0)
|
jamie@57
|
48 #define XTRACT_SR_LIMIT SR_UPPER_LIMIT
|
jamie@57
|
49 #define XTRACT_FFT_BANDS_MIN 16
|
jamie@57
|
50 #define XTRACT_FFT_BANDS_MAX 65536
|
jamie@57
|
51 #define XTRACT_FFT_BANDS_DEF 1024
|
jamie@57
|
52 #define XTRACT_SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth \
|
jamie@57
|
53 (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/
|
jamie@73
|
54 #define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */
|
jamie@57
|
55 #define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */
|
jamie@98
|
56 #define XTRACT_ARRAY_ELEMENTS(_array) (sizeof(_array)/sizeof(_array[0]))
|
jamie@57
|
57
|
jamie@57
|
58 #endif
|