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.

271 lines
9.3KB

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