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.

276 lines
9.2KB

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