annotate src/Support/Common.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 bd370910aa05
children 491b1b1d1dc5
rev   line source
tomwalters@0 1 // Copyright 2006-2010, Thomas Walters, Willem van Engen
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@0 20 * \brief Common includes for all AIM-C
tomwalters@0 21 */
tomwalters@0 22
tomwalters@0 23 /*! \author: Thomas Walters <tom@acousticscale.org>
tomwalters@0 24 * \author: Willem van Engen <cnbh@willem.engen.nl>
tomwalters@0 25 * \date 2010/01/30
tomwalters@0 26 * \version \$Id: Common.h 1 2010-02-02 11:04:50Z tcw $
tomwalters@0 27 */
tomwalters@0 28
tomwalters@11 29 #ifndef AIMC_SUPPORT_COMMON_H_
tomwalters@11 30 #define AIMC_SUPPORT_COMMON_H_
tomwalters@0 31
tomwalters@0 32 #include <stdlib.h>
tomwalters@0 33 #include <stdio.h>
tomwalters@0 34 #include <stdarg.h>
tomwalters@0 35
tomwalters@0 36 // A macro to disallow the copy constructor and operator= functions
tomwalters@0 37 // This should be used in the private: declarations for a class
tomwalters@0 38 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
tomwalters@0 39 TypeName(const TypeName&); \
tomwalters@0 40 void operator=(const TypeName&)
tomwalters@0 41
tomwalters@0 42 #if !defined(_T)
tomwalters@0 43 # ifdef _UNICODE
tomwalters@0 44 # define _T(x) L ## x
tomwalters@0 45 # else
tomwalters@0 46 # define _T(x) x
tomwalters@0 47 # endif
tomwalters@0 48 #endif
tomwalters@0 49
tomwalters@0 50 /*! \brief C++ delete if != NULL
tomwalters@0 51 *
tomwalters@0 52 * This was used so often, that is was moved to a macro.
tomwalters@0 53 */
tomwalters@0 54 #define DELETE_IF_NONNULL(x) { \
tomwalters@0 55 if ( (x) ) { \
tomwalters@0 56 delete (x); \
tomwalters@0 57 (x) = NULL; \
tomwalters@0 58 } \
tomwalters@0 59 }
tomwalters@0 60
tomwalters@0 61 /*! \brief C++ delete[] if != NULL
tomwalters@0 62 *
tomwalters@0 63 * This was used so often, that is was moved to a macro.
tomwalters@0 64 */
tomwalters@0 65 #define DELETE_ARRAY_IF_NONNULL(x) { \
tomwalters@0 66 if ( (x) ) { \
tomwalters@0 67 delete[] (x); \
tomwalters@0 68 (x) = NULL; \
tomwalters@0 69 } \
tomwalters@0 70 }
tomwalters@0 71
tomwalters@0 72 /*! \brief C free if != NULL
tomwalters@0 73 *
tomwalters@0 74 * This was used so often, that is was moved to a macro.
tomwalters@0 75 */
tomwalters@0 76 #define FREE_IF_NONNULL(x) { \
tomwalters@0 77 if ( (x) ) { \
tomwalters@0 78 free(x); \
tomwalters@0 79 (x) = NULL; \
tomwalters@0 80 } \
tomwalters@0 81 }
tomwalters@0 82
tomwalters@0 83 #ifdef DEBUG
tomwalters@0 84 # define AIM_VERIFY(x) AIM_ASSERT(x)
tomwalters@0 85 # define AIM_ASSERT(x) { \
tomwalters@0 86 if (!(x)) { \
tomwalters@0 87 LOG_ERROR("Assertion failed.\n"); \
tomwalters@8 88 *(reinterpret_cast<char*>(0)) = 0; \
tomwalters@0 89 } \
tomwalters@0 90 }
tomwalters@0 91 #else
tomwalters@0 92 # define AIM_VERIFY(x) {x;}
tomwalters@0 93 # define AIM_ASSERT(...)
tomwalters@0 94 #endif
tomwalters@0 95
tomwalters@0 96 namespace aimc {
tomwalters@0 97 void LOG_ERROR(const char *sFmt, ...);
tomwalters@0 98 void LOG_INFO(const char *sFmt, ...);
tomwalters@6 99 void LOG_INFO_NN(const char *sFmt, ...);
tomwalters@0 100 } // namespace aimc
tomwalters@0 101
tomwalters@11 102 #endif // AIMC_SUPPORT_COMMON_H_