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.

283 lines
9.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. /*******************************************************************************
  19. The block below describes the properties of this module, and is read by
  20. the Projucer to automatically generate project code that uses it.
  21. For details about the syntax and how to create or use a module, see the
  22. JUCE Module Format.md file.
  23. BEGIN_JUCE_MODULE_DECLARATION
  24. ID: juce_dsp
  25. vendor: juce
  26. version: 7.0.7
  27. name: JUCE DSP classes
  28. description: Classes for audio buffer manipulation, digital audio processing, filtering, oversampling, fast math functions etc.
  29. website: http://www.juce.com/juce
  30. license: GPL/Commercial
  31. minimumCppStandard: 17
  32. dependencies: juce_audio_formats
  33. OSXFrameworks: Accelerate
  34. iOSFrameworks: Accelerate
  35. END_JUCE_MODULE_DECLARATION
  36. *******************************************************************************/
  37. #pragma once
  38. #define JUCE_DSP_H_INCLUDED
  39. #include <juce_audio_basics/juce_audio_basics.h>
  40. #include <juce_audio_formats/juce_audio_formats.h>
  41. #if defined (_M_X64) || defined (__amd64__) || defined (__SSE2__) || (defined (_M_IX86_FP) && _M_IX86_FP == 2)
  42. #if defined (_M_X64) || defined (__amd64__)
  43. #ifndef __SSE2__
  44. #define __SSE2__
  45. #endif
  46. #endif
  47. #ifndef JUCE_USE_SIMD
  48. #define JUCE_USE_SIMD 1
  49. #endif
  50. #if JUCE_USE_SIMD
  51. #include <immintrin.h>
  52. #endif
  53. // it's ok to check for _M_ARM below as this is only defined on Windows for Arm 32-bit
  54. // which has a minimum requirement of armv7, which supports neon.
  55. #elif defined (__ARM_NEON__) || defined (__ARM_NEON) || defined (__arm64__) || defined (__aarch64__) || defined (_M_ARM) || defined (_M_ARM64)
  56. #ifndef JUCE_USE_SIMD
  57. #define JUCE_USE_SIMD 1
  58. #endif
  59. #include <arm_neon.h>
  60. #else
  61. // No SIMD Support
  62. #ifndef JUCE_USE_SIMD
  63. #define JUCE_USE_SIMD 0
  64. #endif
  65. #endif
  66. #ifndef JUCE_VECTOR_CALLTYPE
  67. // __vectorcall does not work on 64-bit due to internal compiler error in
  68. // release mode VS2017. Re-enable when Microsoft fixes this
  69. #if _MSC_VER && JUCE_USE_SIMD && ! (defined (_M_X64) || defined (__amd64__))
  70. #define JUCE_VECTOR_CALLTYPE __vectorcall
  71. #else
  72. #define JUCE_VECTOR_CALLTYPE
  73. #endif
  74. #endif
  75. #include <complex>
  76. //==============================================================================
  77. /** Config: JUCE_ASSERTION_FIRFILTER
  78. When this flag is enabled, an assertion will be generated during the
  79. execution of DEBUG configurations if you use a FIRFilter class to process
  80. FIRCoefficients with a size higher than 128, to tell you that's it would be
  81. more efficient to use the Convolution class instead. It is enabled by
  82. default, but you may want to disable it if you really want to process such
  83. a filter in the time domain.
  84. */
  85. #ifndef JUCE_ASSERTION_FIRFILTER
  86. #define JUCE_ASSERTION_FIRFILTER 1
  87. #endif
  88. /** Config: JUCE_DSP_USE_INTEL_MKL
  89. If this flag is set, then JUCE will use Intel's MKL for JUCE's FFT and
  90. convolution classes.
  91. If you're using the Projucer's Visual Studio exporter, you should also set
  92. the "Use MKL Library (oneAPI)" option in the exporter settings to
  93. "Sequential" or "Parallel". If you're not using the Visual Studio exporter,
  94. the folder containing the mkl_dfti.h header must be in your header search
  95. paths, and you must link against all the necessary MKL libraries.
  96. */
  97. #ifndef JUCE_DSP_USE_INTEL_MKL
  98. #define JUCE_DSP_USE_INTEL_MKL 0
  99. #endif
  100. /** Config: JUCE_DSP_USE_SHARED_FFTW
  101. If this flag is set, then JUCE will search for the fftw shared libraries
  102. at runtime and use the library for JUCE's FFT and convolution classes.
  103. If the library is not found, then JUCE's fallback FFT routines will be used.
  104. This is especially useful on linux as fftw often comes pre-installed on
  105. popular linux distros.
  106. You must respect the FFTW license when enabling this option.
  107. */
  108. #ifndef JUCE_DSP_USE_SHARED_FFTW
  109. #define JUCE_DSP_USE_SHARED_FFTW 0
  110. #endif
  111. /** Config: JUCE_DSP_USE_STATIC_FFTW
  112. If this flag is set, then JUCE will use the statically linked fftw libraries
  113. for JUCE's FFT and convolution classes.
  114. You must add the fftw header/library folder to the extra header/library search
  115. paths of your JUCE project. You also need to add the fftw library itself
  116. to the extra libraries supplied to your JUCE project during linking.
  117. You must respect the FFTW license when enabling this option.
  118. */
  119. #ifndef JUCE_DSP_USE_STATIC_FFTW
  120. #define JUCE_DSP_USE_STATIC_FFTW 0
  121. #endif
  122. /** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO
  123. Enables code in the dsp module to avoid floating point denormals during the
  124. processing of some of the dsp module's filters.
  125. Enabling this will add a slight performance overhead to the DSP module's
  126. filters and algorithms. If your audio app already disables denormals altogether
  127. (for example, by using the ScopedNoDenormals class or the
  128. FloatVectorOperations::disableDenormalisedNumberSupport method), then you
  129. can safely disable this flag to shave off a few cpu cycles from the DSP module's
  130. filters and algorithms.
  131. */
  132. #ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO
  133. #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1
  134. #endif
  135. //==============================================================================
  136. #undef Complex // apparently some C libraries actually define these symbols (!)
  137. #undef Factor
  138. #undef check
  139. namespace juce::dsp
  140. {
  141. template <typename Type>
  142. using Complex = std::complex<Type>;
  143. template <size_t len, typename T>
  144. using FixedSizeFunction = juce::FixedSizeFunction<len, T>;
  145. //==============================================================================
  146. namespace util
  147. {
  148. /** Use this function to prevent denormals on intel CPUs.
  149. This function will work with both primitives and simple containers.
  150. */
  151. #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
  152. inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  153. #ifndef DOXYGEN
  154. inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  155. inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  156. #endif
  157. #else
  158. inline void snapToZero ([[maybe_unused]] float& x) noexcept {}
  159. #ifndef DOXYGEN
  160. inline void snapToZero ([[maybe_unused]] double& x) noexcept {}
  161. inline void snapToZero ([[maybe_unused]] long double& x) noexcept {}
  162. #endif
  163. #endif
  164. }
  165. }
  166. //==============================================================================
  167. #if JUCE_USE_SIMD
  168. #include "native/juce_SIMDNativeOps_fallback.h"
  169. // include the correct native file for this build target CPU
  170. #if defined (__i386__) || defined (__amd64__) || defined (_M_X64) || defined (_X86_) || defined (_M_IX86)
  171. #ifdef __AVX2__
  172. #include "native/juce_SIMDNativeOps_avx.h"
  173. #else
  174. #include "native/juce_SIMDNativeOps_sse.h"
  175. #endif
  176. #elif JUCE_ARM
  177. #include "native/juce_SIMDNativeOps_neon.h"
  178. #else
  179. #error "SIMD register support not implemented for this platform"
  180. #endif
  181. #include "containers/juce_SIMDRegister.h"
  182. #include "containers/juce_SIMDRegister_Impl.h"
  183. #endif
  184. #include "maths/juce_SpecialFunctions.h"
  185. #include "maths/juce_Matrix.h"
  186. #include "maths/juce_Phase.h"
  187. #include "maths/juce_Polynomial.h"
  188. #include "maths/juce_FastMathApproximations.h"
  189. #include "maths/juce_LookupTable.h"
  190. #include "maths/juce_LogRampedValue.h"
  191. #include "containers/juce_AudioBlock.h"
  192. #include "processors/juce_ProcessContext.h"
  193. #include "processors/juce_ProcessorWrapper.h"
  194. #include "processors/juce_ProcessorChain.h"
  195. #include "processors/juce_ProcessorDuplicator.h"
  196. #include "processors/juce_IIRFilter.h"
  197. #include "processors/juce_IIRFilter_Impl.h"
  198. #include "processors/juce_FIRFilter.h"
  199. #include "processors/juce_StateVariableFilter.h"
  200. #include "processors/juce_FirstOrderTPTFilter.h"
  201. #include "processors/juce_Panner.h"
  202. #include "processors/juce_DelayLine.h"
  203. #include "processors/juce_Oversampling.h"
  204. #include "processors/juce_BallisticsFilter.h"
  205. #include "processors/juce_LinkwitzRileyFilter.h"
  206. #include "processors/juce_DryWetMixer.h"
  207. #include "processors/juce_StateVariableTPTFilter.h"
  208. #include "frequency/juce_FFT.h"
  209. #include "frequency/juce_Convolution.h"
  210. #include "frequency/juce_Windowing.h"
  211. #include "filter_design/juce_FilterDesign.h"
  212. #include "widgets/juce_Reverb.h"
  213. #include "widgets/juce_Bias.h"
  214. #include "widgets/juce_Gain.h"
  215. #include "widgets/juce_WaveShaper.h"
  216. #include "widgets/juce_Oscillator.h"
  217. #include "widgets/juce_LadderFilter.h"
  218. #include "widgets/juce_Compressor.h"
  219. #include "widgets/juce_NoiseGate.h"
  220. #include "widgets/juce_Limiter.h"
  221. #include "widgets/juce_Phaser.h"
  222. #include "widgets/juce_Chorus.h"