Audio plugin host https://kx.studio/carla
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.

278 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.1
  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: 14
  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) || defined(__riscv) || defined(__EMSCRIPTEN__)
  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. #elif defined (__ARM_NEON__) || defined (__ARM_NEON) || defined (__arm64__) || defined (__aarch64__)
  54. #ifndef JUCE_USE_SIMD
  55. #define JUCE_USE_SIMD 1
  56. #endif
  57. #include <arm_neon.h>
  58. #else
  59. // No SIMD Support
  60. #ifndef JUCE_USE_SIMD
  61. #define JUCE_USE_SIMD 0
  62. #endif
  63. #endif
  64. #ifndef JUCE_VECTOR_CALLTYPE
  65. // __vectorcall does not work on 64-bit due to internal compiler error in
  66. // release mode VS2017. Re-enable when Microsoft fixes this
  67. #if _MSC_VER && JUCE_USE_SIMD && ! (defined(_M_X64) || defined(__amd64__))
  68. #define JUCE_VECTOR_CALLTYPE __vectorcall
  69. #else
  70. #define JUCE_VECTOR_CALLTYPE
  71. #endif
  72. #endif
  73. #include <complex>
  74. //==============================================================================
  75. /** Config: JUCE_ASSERTION_FIRFILTER
  76. When this flag is enabled, an assertion will be generated during the
  77. execution of DEBUG configurations if you use a FIRFilter class to process
  78. FIRCoefficients with a size higher than 128, to tell you that's it would be
  79. more efficient to use the Convolution class instead. It is enabled by
  80. default, but you may want to disable it if you really want to process such
  81. a filter in the time domain.
  82. */
  83. #ifndef JUCE_ASSERTION_FIRFILTER
  84. #define JUCE_ASSERTION_FIRFILTER 1
  85. #endif
  86. /** Config: JUCE_DSP_USE_INTEL_MKL
  87. If this flag is set, then JUCE will use Intel's MKL for JUCE's FFT and
  88. convolution classes.
  89. If you're using the Projucer's Visual Studio exporter, you should also set
  90. the "Use MKL Library (oneAPI)" option in the exporter settings to
  91. "Sequential" or "Parallel". If you're not using the Visual Studio exporter,
  92. the folder containing the mkl_dfti.h header must be in your header search
  93. paths, and you must link against all the necessary MKL libraries.
  94. */
  95. #ifndef JUCE_DSP_USE_INTEL_MKL
  96. #define JUCE_DSP_USE_INTEL_MKL 0
  97. #endif
  98. /** Config: JUCE_DSP_USE_SHARED_FFTW
  99. If this flag is set, then JUCE will search for the fftw shared libraries
  100. at runtime and use the library for JUCE's FFT and convolution classes.
  101. If the library is not found, then JUCE's fallback FFT routines will be used.
  102. This is especially useful on linux as fftw often comes pre-installed on
  103. popular linux distros.
  104. You must respect the FFTW license when enabling this option.
  105. */
  106. #ifndef JUCE_DSP_USE_SHARED_FFTW
  107. #define JUCE_DSP_USE_SHARED_FFTW 0
  108. #endif
  109. /** Config: JUCE_DSP_USE_STATIC_FFTW
  110. If this flag is set, then JUCE will use the statically linked fftw libraries
  111. for JUCE's FFT and convolution classes.
  112. You must add the fftw header/library folder to the extra header/library search
  113. paths of your JUCE project. You also need to add the fftw library itself
  114. to the extra libraries supplied to your JUCE project during linking.
  115. You must respect the FFTW license when enabling this option.
  116. */
  117. #ifndef JUCE_DSP_USE_STATIC_FFTW
  118. #define JUCE_DSP_USE_STATIC_FFTW 0
  119. #endif
  120. /** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO
  121. Enables code in the dsp module to avoid floating point denormals during the
  122. processing of some of the dsp module's filters.
  123. Enabling this will add a slight performance overhead to the DSP module's
  124. filters and algorithms. If your audio app already disables denormals altogether
  125. (for example, by using the ScopedNoDenormals class or the
  126. FloatVectorOperations::disableDenormalisedNumberSupport method), then you
  127. can safely disable this flag to shave off a few cpu cycles from the DSP module's
  128. filters and algorithms.
  129. */
  130. #ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO
  131. #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1
  132. #endif
  133. //==============================================================================
  134. #undef Complex // apparently some C libraries actually define these symbols (!)
  135. #undef Factor
  136. #undef check
  137. namespace juce
  138. {
  139. namespace dsp
  140. {
  141. template <typename Type>
  142. using Complex = std::complex<Type>;
  143. //==============================================================================
  144. namespace util
  145. {
  146. /** Use this function to prevent denormals on intel CPUs.
  147. This function will work with both primitives and simple containers.
  148. */
  149. #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
  150. inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  151. #ifndef DOXYGEN
  152. inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  153. inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  154. #endif
  155. #else
  156. inline void snapToZero (float& x) noexcept { ignoreUnused (x); }
  157. #ifndef DOXYGEN
  158. inline void snapToZero (double& x) noexcept { ignoreUnused (x); }
  159. inline void snapToZero (long double& x) noexcept { ignoreUnused (x); }
  160. #endif
  161. #endif
  162. }
  163. }
  164. }
  165. //==============================================================================
  166. #if JUCE_USE_SIMD
  167. #include "native/juce_fallback_SIMDNativeOps.h"
  168. // include the correct native file for this build target CPU
  169. #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) || defined(__riscv) || defined(__EMSCRIPTEN__)
  170. #ifdef __AVX2__
  171. #include "native/juce_avx_SIMDNativeOps.h"
  172. #else
  173. #include "native/juce_sse_SIMDNativeOps.h"
  174. #endif
  175. #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__)
  176. #include "native/juce_neon_SIMDNativeOps.h"
  177. #else
  178. #error "SIMD register support not implemented for this platform"
  179. #endif
  180. #include "containers/juce_SIMDRegister.h"
  181. #endif
  182. #include "maths/juce_SpecialFunctions.h"
  183. #include "maths/juce_Matrix.h"
  184. #include "maths/juce_Phase.h"
  185. #include "maths/juce_Polynomial.h"
  186. #include "maths/juce_FastMathApproximations.h"
  187. #include "maths/juce_LookupTable.h"
  188. #include "maths/juce_LogRampedValue.h"
  189. #include "containers/juce_AudioBlock.h"
  190. #include "containers/juce_FixedSizeFunction.h"
  191. #include "processors/juce_ProcessContext.h"
  192. #include "processors/juce_ProcessorWrapper.h"
  193. #include "processors/juce_ProcessorChain.h"
  194. #include "processors/juce_ProcessorDuplicator.h"
  195. #include "processors/juce_IIRFilter.h"
  196. #include "processors/juce_FIRFilter.h"
  197. #include "processors/juce_StateVariableFilter.h"
  198. #include "processors/juce_FirstOrderTPTFilter.h"
  199. #include "processors/juce_Panner.h"
  200. #include "processors/juce_DelayLine.h"
  201. #include "processors/juce_Oversampling.h"
  202. #include "processors/juce_BallisticsFilter.h"
  203. #include "processors/juce_LinkwitzRileyFilter.h"
  204. #include "processors/juce_DryWetMixer.h"
  205. #include "processors/juce_StateVariableTPTFilter.h"
  206. #include "frequency/juce_FFT.h"
  207. #include "frequency/juce_Convolution.h"
  208. #include "frequency/juce_Windowing.h"
  209. #include "filter_design/juce_FilterDesign.h"
  210. #include "widgets/juce_Reverb.h"
  211. #include "widgets/juce_Bias.h"
  212. #include "widgets/juce_Gain.h"
  213. #include "widgets/juce_WaveShaper.h"
  214. #include "widgets/juce_Oscillator.h"
  215. #include "widgets/juce_LadderFilter.h"
  216. #include "widgets/juce_Compressor.h"
  217. #include "widgets/juce_NoiseGate.h"
  218. #include "widgets/juce_Limiter.h"
  219. #include "widgets/juce_Phaser.h"
  220. #include "widgets/juce_Chorus.h"