jamie@141: /* jamie@141: * Copyright (C) 2012 Jamie Bullock jamie@57: * jamie@141: * Permission is hereby granted, free of charge, to any person obtaining a copy jamie@141: * of this software and associated documentation files (the "Software"), to jamie@141: * deal in the Software without restriction, including without limitation the jamie@141: * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or jamie@141: * sell copies of the Software, and to permit persons to whom the Software is jamie@141: * furnished to do so, subject to the following conditions: jamie@57: * jamie@141: * The above copyright notice and this permission notice shall be included in jamie@141: * all copies or substantial portions of the Software. jamie@57: * jamie@141: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR jamie@141: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, jamie@141: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE jamie@141: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER jamie@141: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING jamie@141: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS jamie@141: * IN THE SOFTWARE. jamie@141: * jamie@57: */ jamie@57: jamie@57: /** \file xtract_macros_private.h: defines useful internal macros */ jamie@57: jamie@57: #ifndef XTRACT_MACROS_PRIVATE_H jamie@57: #define XTRACT_MACROS_PRIVATE_H jamie@57: jamie@57: #include jamie@57: jamie@57: #define XTRACT_SQ(a) ((a) * (a)) jamie@57: #define XTRACT_MIN(a, b) ((a) < (b) ? (a) : (b)) jamie@57: #define XTRACT_MAX(a, b) ((a) > (b) ? (a) : (b)) jamie@57: #define XTRACT_VERY_SMALL_NUMBER 2e-42 jamie@57: #define XTRACT_LOG_LIMIT XTRACT_VERY_SMALL_NUMBER jamie@73: #define XTRACT_LOG_LIMIT_DB -96.0 jamie@73: #define XTRACT_DB_SCALE_OFFSET 96.0 jamie@57: #define XTRACT_VERY_BIG_NUMBER 2e42 jamie@73: #define XTRACT_SR_UPPER_LIMIT 192000.0 jamie@73: #define XTRACT_SR_LOWER_LIMIT 22050.0 jamie@73: #define XTRACT_SR_DEFAULT 44100.0 jamie@73: #define XTRACT_FUNDAMENTAL_DEFAULT 440.0 jamie@57: #define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2 jamie@57: #define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N jamie@120: #define XTRACT_GET_MAX max = result[m] > max ? result[m] : max jamie@120: #define XTRACT_SET_FREQUENCY result[M + m] = n * q jamie@59: #define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0) jamie@57: #define XTRACT_SR_LIMIT SR_UPPER_LIMIT jamie@57: #define XTRACT_FFT_BANDS_MIN 16 jamie@57: #define XTRACT_FFT_BANDS_MAX 65536 jamie@57: #define XTRACT_FFT_BANDS_DEF 1024 jamie@57: #define XTRACT_SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth \ jamie@57: (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/ jamie@73: #define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */ jamie@57: #define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */ jamie@98: #define XTRACT_ARRAY_ELEMENTS(_array) (sizeof(_array)/sizeof(_array[0])) jamie@57: jamie@57: #endif