The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

239 lines
7.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. /*******************************************************************************
  20. The block below describes the properties of this module, and is read by
  21. the Projucer to automatically generate project code that uses it.
  22. For details about the syntax and how to create or use a module, see the
  23. JUCE Module Format.txt file.
  24. BEGIN_JUCE_MODULE_DECLARATION
  25. ID: juce_dsp
  26. vendor: juce
  27. version: 5.1.1
  28. name: JUCE DSP classes
  29. description: Classes for audio buffer manipulation, digital audio processing, filtering, oversampling, fast math functions etc.
  30. website: http://www.juce.com/juce
  31. license: GPL/Commercial
  32. minimumCppStandard: 14
  33. dependencies: juce_core, juce_audio_basics, juce_audio_formats
  34. OSXFrameworks: Accelerate
  35. iOSFrameworks: Accelerate
  36. END_JUCE_MODULE_DECLARATION
  37. *******************************************************************************/
  38. #pragma once
  39. #define JUCE_DSP_H_INCLUDED
  40. #include <juce_audio_basics/juce_audio_basics.h>
  41. #include <juce_audio_formats/juce_audio_formats.h>
  42. #if defined(_M_X64) || defined(__amd64__) || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP == 2)
  43. #if defined(_M_X64) || defined(__amd64__)
  44. #ifndef __SSE2__
  45. #define __SSE2__
  46. #endif
  47. #endif
  48. #ifndef JUCE_USE_SIMD
  49. #define JUCE_USE_SIMD 1
  50. #endif
  51. #if JUCE_USE_SIMD
  52. #include <immintrin.h>
  53. #endif
  54. #elif defined (__ARM_NEON__) || defined (__ARM_NEON) || defined (__arm64__) || defined (__aarch64__)
  55. #ifndef JUCE_USE_SIMD
  56. #define JUCE_USE_SIMD 1
  57. #endif
  58. #include <arm_neon.h>
  59. #else
  60. // No SIMD Support
  61. #ifndef JUCE_USE_SIMD
  62. #define JUCE_USE_SIMD 0
  63. #endif
  64. #endif
  65. #ifndef JUCE_VECTOR_CALLTYPE
  66. // __vectorcall does not work on 64-bit due to internal compiler error in
  67. // release mode in both VS2015 and VS2017. Re-enable when Microsoft fixes this
  68. #if _MSC_VER && JUCE_USE_SIMD && ! (defined(_M_X64) || defined(__amd64__))
  69. #define JUCE_VECTOR_CALLTYPE __vectorcall
  70. #else
  71. #define JUCE_VECTOR_CALLTYPE
  72. #endif
  73. #endif
  74. #include <atomic>
  75. #include <complex>
  76. #include <cmath>
  77. #include <array>
  78. //==============================================================================
  79. /** Config: JUCE_ASSERTION_FIRFILTER
  80. When this flag is enabled, an assertion will be generated during the
  81. execution of DEBUG configurations if you use a FIRFilter class to process
  82. FIRCoefficients with a size higher than 128, to tell you that's it would be
  83. more efficient to use the Convolution class instead. It is enabled by
  84. default, but you may want to disable it if you really want to process such
  85. a filter in the time domain.
  86. */
  87. #ifndef JUCE_ASSERTION_FIRFILTER
  88. #define JUCE_ASSERTION_FIRFILTER 1
  89. #endif
  90. /** Config: JUCE_DSP_USE_INTEL_MKL
  91. If this flag is set, then JUCE will use Intel's MKL for JUCE's FFT and
  92. convolution classes.
  93. The folder containing the mkl_dfti.h header must be in your header
  94. search paths when using this flag. You also need to add all the necessary
  95. intel mkl libraries to the "External Libraries to Link" field in the
  96. Projucer.
  97. */
  98. #ifndef JUCE_DSP_USE_INTEL_MKL
  99. #define JUCE_DSP_USE_INTEL_MKL 0
  100. #endif
  101. /** Config: JUCE_DSP_USE_SHARED_FFTW
  102. If this flag is set, then JUCE will search for the fftw shared libraries
  103. at runtime and use the library for JUCE's FFT and convolution classes.
  104. If the library is not found, then JUCE's fallback FFT routines will be used.
  105. This is especially useful on linux as fftw often comes pre-installed on
  106. popular linux distros.
  107. You must respect the FFTW license when enabling this option.
  108. */
  109. #ifndef JUCE_DSP_USE_SHARED_FFTW
  110. #define JUCE_DSP_USE_SHARED_FFTW 0
  111. #endif
  112. /** Config: JUCE_DSP_USE_STATIC_FFTW
  113. If this flag is set, then JUCE will use the statically linked fftw libraries
  114. for JUCE's FFT and convolution classes.
  115. You must add the fftw header/library folder to the extra header/library search
  116. paths of your JUCE project. You also need to add the fftw library itself
  117. to the extra libraries supplied to your JUCE project during linking.
  118. You must respect the FFTW license when enabling this option.
  119. */
  120. #ifndef JUCE_DSP_USE_STATIC_FFTW
  121. #define JUCE_DSP_USE_STATIC_FFTW 0
  122. #endif
  123. //==============================================================================
  124. #undef Complex // apparently some C libraries actually define these symbols (!)
  125. #undef Factor
  126. namespace juce
  127. {
  128. namespace dsp
  129. {
  130. template <typename Type>
  131. using Complex = ::std::complex<Type>;
  132. //==============================================================================
  133. namespace util
  134. {
  135. /** Use this function to prevent denormals on intel CPUs.
  136. This function will work with both primitives and simple containers.
  137. */
  138. inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  139. #ifndef DOXYGEN
  140. inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  141. inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  142. #endif
  143. }
  144. }
  145. }
  146. //==============================================================================
  147. #if JUCE_USE_SIMD
  148. #include "native/juce_fallback_SIMDNativeOps.h"
  149. // include the correct native file for this build target CPU
  150. #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86)
  151. #ifdef __AVX2__
  152. #include "native/juce_avx_SIMDNativeOps.h"
  153. #else
  154. #include "native/juce_sse_SIMDNativeOps.h"
  155. #endif
  156. #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__)
  157. #include "native/juce_neon_SIMDNativeOps.h"
  158. #else
  159. #error "SIMD register support not implemented for this platform"
  160. #endif
  161. #include "containers/juce_SIMDRegister.h"
  162. #endif
  163. #include "maths/juce_SpecialFunctions.h"
  164. #include "maths/juce_Matrix.h"
  165. #include "maths/juce_Polynomial.h"
  166. #include "maths/juce_FastMathApproximations.h"
  167. #include "maths/juce_LookupTable.h"
  168. #include "containers/juce_AudioBlock.h"
  169. #include "processors/juce_ProcessContext.h"
  170. #include "processors/juce_ProcessorWrapper.h"
  171. #include "processors/juce_ProcessorChain.h"
  172. #include "processors/juce_ProcessorDuplicator.h"
  173. #include "processors/juce_Bias.h"
  174. #include "processors/juce_Gain.h"
  175. #include "processors/juce_WaveShaper.h"
  176. #include "processors/juce_IIRFilter.h"
  177. #include "processors/juce_FIRFilter.h"
  178. #include "processors/juce_Oscillator.h"
  179. #include "processors/juce_StateVariableFilter.h"
  180. #include "processors/juce_Oversampling.h"
  181. #include "frequency/juce_FFT.h"
  182. #include "frequency/juce_Convolution.h"
  183. #include "frequency/juce_Windowing.h"
  184. #include "filter_design/juce_FilterDesign.h"