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.

279 lines
9.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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: 6.0.4
  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)
  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 in both VS2015 and 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 <atomic>
  74. #include <complex>
  75. #include <cmath>
  76. #include <array>
  77. //==============================================================================
  78. /** Config: JUCE_ASSERTION_FIRFILTER
  79. When this flag is enabled, an assertion will be generated during the
  80. execution of DEBUG configurations if you use a FIRFilter class to process
  81. FIRCoefficients with a size higher than 128, to tell you that's it would be
  82. more efficient to use the Convolution class instead. It is enabled by
  83. default, but you may want to disable it if you really want to process such
  84. a filter in the time domain.
  85. */
  86. #ifndef JUCE_ASSERTION_FIRFILTER
  87. #define JUCE_ASSERTION_FIRFILTER 1
  88. #endif
  89. /** Config: JUCE_DSP_USE_INTEL_MKL
  90. If this flag is set, then JUCE will use Intel's MKL for JUCE's FFT and
  91. convolution classes.
  92. The folder containing the mkl_dfti.h header must be in your header
  93. search paths when using this flag. You also need to add all the necessary
  94. intel mkl libraries to the "External Libraries to Link" field in the
  95. Projucer.
  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
  140. {
  141. namespace dsp
  142. {
  143. template <typename Type>
  144. using Complex = std::complex<Type>;
  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 (float& x) noexcept { ignoreUnused (x); }
  159. #ifndef DOXYGEN
  160. inline void snapToZero (double& x) noexcept { ignoreUnused (x); }
  161. inline void snapToZero (long double& x) noexcept { ignoreUnused (x); }
  162. #endif
  163. #endif
  164. }
  165. }
  166. }
  167. //==============================================================================
  168. #if JUCE_USE_SIMD
  169. #include "native/juce_fallback_SIMDNativeOps.h"
  170. // include the correct native file for this build target CPU
  171. #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86)
  172. #ifdef __AVX2__
  173. #include "native/juce_avx_SIMDNativeOps.h"
  174. #else
  175. #include "native/juce_sse_SIMDNativeOps.h"
  176. #endif
  177. #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__)
  178. #include "native/juce_neon_SIMDNativeOps.h"
  179. #else
  180. #error "SIMD register support not implemented for this platform"
  181. #endif
  182. #include "containers/juce_SIMDRegister.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_FIRFilter.h"
  198. #include "processors/juce_StateVariableFilter.h"
  199. #include "processors/juce_FirstOrderTPTFilter.h"
  200. #include "processors/juce_Panner.h"
  201. #include "processors/juce_DelayLine.h"
  202. #include "processors/juce_Oversampling.h"
  203. #include "processors/juce_BallisticsFilter.h"
  204. #include "processors/juce_LinkwitzRileyFilter.h"
  205. #include "processors/juce_DryWetMixer.h"
  206. #include "processors/juce_StateVariableTPTFilter.h"
  207. #include "frequency/juce_FFT.h"
  208. #include "frequency/juce_Convolution.h"
  209. #include "frequency/juce_Windowing.h"
  210. #include "filter_design/juce_FilterDesign.h"
  211. #include "widgets/juce_Reverb.h"
  212. #include "widgets/juce_Bias.h"
  213. #include "widgets/juce_Gain.h"
  214. #include "widgets/juce_WaveShaper.h"
  215. #include "widgets/juce_Oscillator.h"
  216. #include "widgets/juce_LadderFilter.h"
  217. #include "widgets/juce_Compressor.h"
  218. #include "widgets/juce_NoiseGate.h"
  219. #include "widgets/juce_Limiter.h"
  220. #include "widgets/juce_Phaser.h"
  221. #include "widgets/juce_Chorus.h"