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.

277 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.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: 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 <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. The folder containing the mkl_dfti.h header must be in your header
  90. search paths when using this flag. You also need to add all the necessary
  91. intel mkl libraries to the "External Libraries to Link" field in the
  92. Projucer.
  93. */
  94. #ifndef JUCE_DSP_USE_INTEL_MKL
  95. #define JUCE_DSP_USE_INTEL_MKL 0
  96. #endif
  97. /** Config: JUCE_DSP_USE_SHARED_FFTW
  98. If this flag is set, then JUCE will search for the fftw shared libraries
  99. at runtime and use the library for JUCE's FFT and convolution classes.
  100. If the library is not found, then JUCE's fallback FFT routines will be used.
  101. This is especially useful on linux as fftw often comes pre-installed on
  102. popular linux distros.
  103. You must respect the FFTW license when enabling this option.
  104. */
  105. #ifndef JUCE_DSP_USE_SHARED_FFTW
  106. #define JUCE_DSP_USE_SHARED_FFTW 0
  107. #endif
  108. /** Config: JUCE_DSP_USE_STATIC_FFTW
  109. If this flag is set, then JUCE will use the statically linked fftw libraries
  110. for JUCE's FFT and convolution classes.
  111. You must add the fftw header/library folder to the extra header/library search
  112. paths of your JUCE project. You also need to add the fftw library itself
  113. to the extra libraries supplied to your JUCE project during linking.
  114. You must respect the FFTW license when enabling this option.
  115. */
  116. #ifndef JUCE_DSP_USE_STATIC_FFTW
  117. #define JUCE_DSP_USE_STATIC_FFTW 0
  118. #endif
  119. /** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO
  120. Enables code in the dsp module to avoid floating point denormals during the
  121. processing of some of the dsp module's filters.
  122. Enabling this will add a slight performance overhead to the DSP module's
  123. filters and algorithms. If your audio app already disables denormals altogether
  124. (for example, by using the ScopedNoDenormals class or the
  125. FloatVectorOperations::disableDenormalisedNumberSupport method), then you
  126. can safely disable this flag to shave off a few cpu cycles from the DSP module's
  127. filters and algorithms.
  128. */
  129. #ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO
  130. #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1
  131. #endif
  132. //==============================================================================
  133. #undef Complex // apparently some C libraries actually define these symbols (!)
  134. #undef Factor
  135. #undef check
  136. namespace juce
  137. {
  138. namespace dsp
  139. {
  140. template <typename Type>
  141. using Complex = std::complex<Type>;
  142. //==============================================================================
  143. namespace util
  144. {
  145. /** Use this function to prevent denormals on intel CPUs.
  146. This function will work with both primitives and simple containers.
  147. */
  148. #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
  149. inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  150. #ifndef DOXYGEN
  151. inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  152. inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  153. #endif
  154. #else
  155. inline void snapToZero (float& x) noexcept { ignoreUnused (x); }
  156. #ifndef DOXYGEN
  157. inline void snapToZero (double& x) noexcept { ignoreUnused (x); }
  158. inline void snapToZero (long double& x) noexcept { ignoreUnused (x); }
  159. #endif
  160. #endif
  161. }
  162. }
  163. }
  164. //==============================================================================
  165. #if JUCE_USE_SIMD
  166. #include "native/juce_fallback_SIMDNativeOps.h"
  167. // include the correct native file for this build target CPU
  168. #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86)
  169. #ifdef __AVX2__
  170. #include "native/juce_avx_SIMDNativeOps.h"
  171. #else
  172. #include "native/juce_sse_SIMDNativeOps.h"
  173. #endif
  174. #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__)
  175. #include "native/juce_neon_SIMDNativeOps.h"
  176. #else
  177. #error "SIMD register support not implemented for this platform"
  178. #endif
  179. #include "containers/juce_SIMDRegister.h"
  180. #endif
  181. #include "maths/juce_SpecialFunctions.h"
  182. #include "maths/juce_Matrix.h"
  183. #include "maths/juce_Phase.h"
  184. #include "maths/juce_Polynomial.h"
  185. #include "maths/juce_FastMathApproximations.h"
  186. #include "maths/juce_LookupTable.h"
  187. #include "maths/juce_LogRampedValue.h"
  188. #include "containers/juce_AudioBlock.h"
  189. #include "containers/juce_FixedSizeFunction.h"
  190. #include "processors/juce_ProcessContext.h"
  191. #include "processors/juce_ProcessorWrapper.h"
  192. #include "processors/juce_ProcessorChain.h"
  193. #include "processors/juce_ProcessorDuplicator.h"
  194. #include "processors/juce_IIRFilter.h"
  195. #include "processors/juce_FIRFilter.h"
  196. #include "processors/juce_StateVariableFilter.h"
  197. #include "processors/juce_FirstOrderTPTFilter.h"
  198. #include "processors/juce_Panner.h"
  199. #include "processors/juce_DelayLine.h"
  200. #include "processors/juce_Oversampling.h"
  201. #include "processors/juce_BallisticsFilter.h"
  202. #include "processors/juce_LinkwitzRileyFilter.h"
  203. #include "processors/juce_DryWetMixer.h"
  204. #include "processors/juce_StateVariableTPTFilter.h"
  205. #include "frequency/juce_FFT.h"
  206. #include "frequency/juce_Convolution.h"
  207. #include "frequency/juce_Windowing.h"
  208. #include "filter_design/juce_FilterDesign.h"
  209. #include "widgets/juce_Reverb.h"
  210. #include "widgets/juce_Bias.h"
  211. #include "widgets/juce_Gain.h"
  212. #include "widgets/juce_WaveShaper.h"
  213. #include "widgets/juce_Oscillator.h"
  214. #include "widgets/juce_LadderFilter.h"
  215. #include "widgets/juce_Compressor.h"
  216. #include "widgets/juce_NoiseGate.h"
  217. #include "widgets/juce_Limiter.h"
  218. #include "widgets/juce_Phaser.h"
  219. #include "widgets/juce_Chorus.h"