libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmFloatTypes.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #ifndef cmFloatTypes_h
  4. #define cmFloatTypes_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Declare the types cmReal_t and cmSample_t and define some useful limits." kw:[base]}
  9. //
  10. // For signal processing functions the cm library uses the types cmSample_t to indicate an audio
  11. // sample value and cmReal_t to specify a general purpose floating point value. The library
  12. // is designed in such a way that the actual type, float or double, for these two types may
  13. // be set at compilation time. Set the preprocessor variable CM_FLOAT_SMP to 1 to indicate
  14. // that cmSample_t will be of type 'float' otherwise it will be of type 'double'.
  15. // Set the preprocessor variable CM_FLOAT_REAL to 1 to indicate
  16. // that cmSample_t will be of type 'float' otherwise it will be of type 'double'.
  17. // By default cmSample_t is float nad cmReal_t is double.
  18. //
  19. //-----------------------------------------------------------------
  20. #ifndef CM_FLOAT_SMP
  21. #define CM_FLOAT_SMP 1
  22. #endif
  23. #if CM_FLOAT_SMP == 1
  24. typedef float cmSample_t; // cmSample_t is a float
  25. typedef float _Complex cmComplexS_t;// cmComplexS_t is single precision.
  26. #define cmSample_EPSILON FLT_EPSILON // Minimum increment between 1.0 and the next greaterv value. (1E-5)
  27. #define cmSample_MAX FLT_MAX // Maximum representable number (1E+37).
  28. #define cmSample_MIN FLT_MIN // Minimum representable number (1E-37).
  29. #else
  30. typedef double cmSample_t; // cmSample_t is a double
  31. typedef double _Complex cmComplexS_t; // cmComplexS_t is doulbe precision.
  32. #define cmSample_EPSILON DBL_EPSILON // Minimum increment between 1.0 and the next greaterv value. (1E-9)
  33. #define cmSample_MAX DBL_MAX // Maximum representable number (1E+37).
  34. #define cmSample_MIN DBL_MIN // Minimum representable number (1E-37).
  35. #endif
  36. //-----------------------------------------------------------------
  37. //-----------------------------------------------------------------
  38. //-----------------------------------------------------------------
  39. #ifndef CM_FLOAT_REAL
  40. #define CM_FLOAT_REAL 0
  41. #endif
  42. #if CM_FLOAT_REAL == 1
  43. typedef float cmReal_t; // cmReal_t is a float
  44. typedef float _Complex cmComplexR_t; // cmComplexR_t is single precision.
  45. #define cmReal_EPSILON FLT_EPSILON // Minimum increment between 1.0 and the next greaterv value. (1E-5)
  46. #define cmReal_MAX FLT_MAX // Maximum representable number (1E+37).
  47. #define cmReal_MIN FLT_MIN // Minimum representable number (1E-37).
  48. #else
  49. typedef double cmReal_t; // cmReal_t is a double.
  50. typedef double _Complex cmComplexR_t; // cmComplexR_t is double precision.
  51. #define cmReal_EPSILON DBL_EPSILON // Minimum increment between 1.0 and the next greaterv value (1E-9).
  52. #define cmReal_MAX DBL_MAX // Maximum representable number (1E+37).
  53. #define cmReal_MIN DBL_MIN // Minimum representable number (1E-37).
  54. #endif
  55. //)
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif