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.

260 lines
8.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  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.txt file.
  18. BEGIN_JUCE_MODULE_DECLARATION
  19. ID: juce_dsp
  20. vendor: juce
  21. version: 6.0.0
  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 <atomic>
  69. #include <complex>
  70. #include <cmath>
  71. #include <array>
  72. //==============================================================================
  73. /** Config: JUCE_ASSERTION_FIRFILTER
  74. When this flag is enabled, an assertion will be generated during the
  75. execution of DEBUG configurations if you use a FIRFilter class to process
  76. FIRCoefficients with a size higher than 128, to tell you that's it would be
  77. more efficient to use the Convolution class instead. It is enabled by
  78. default, but you may want to disable it if you really want to process such
  79. a filter in the time domain.
  80. */
  81. #ifndef JUCE_ASSERTION_FIRFILTER
  82. #define JUCE_ASSERTION_FIRFILTER 1
  83. #endif
  84. /** Config: JUCE_DSP_USE_INTEL_MKL
  85. If this flag is set, then JUCE will use Intel's MKL for JUCE's FFT and
  86. convolution classes.
  87. The folder containing the mkl_dfti.h header must be in your header
  88. search paths when using this flag. You also need to add all the necessary
  89. intel mkl libraries to the "External Libraries to Link" field in the
  90. Projucer.
  91. */
  92. #ifndef JUCE_DSP_USE_INTEL_MKL
  93. #define JUCE_DSP_USE_INTEL_MKL 0
  94. #endif
  95. /** Config: JUCE_DSP_USE_SHARED_FFTW
  96. If this flag is set, then JUCE will search for the fftw shared libraries
  97. at runtime and use the library for JUCE's FFT and convolution classes.
  98. If the library is not found, then JUCE's fallback FFT routines will be used.
  99. This is especially useful on linux as fftw often comes pre-installed on
  100. popular linux distros.
  101. You must respect the FFTW license when enabling this option.
  102. */
  103. #ifndef JUCE_DSP_USE_SHARED_FFTW
  104. #define JUCE_DSP_USE_SHARED_FFTW 0
  105. #endif
  106. /** Config: JUCE_DSP_USE_STATIC_FFTW
  107. If this flag is set, then JUCE will use the statically linked fftw libraries
  108. for JUCE's FFT and convolution classes.
  109. You must add the fftw header/library folder to the extra header/library search
  110. paths of your JUCE project. You also need to add the fftw library itself
  111. to the extra libraries supplied to your JUCE project during linking.
  112. You must respect the FFTW license when enabling this option.
  113. */
  114. #ifndef JUCE_DSP_USE_STATIC_FFTW
  115. #define JUCE_DSP_USE_STATIC_FFTW 0
  116. #endif
  117. /** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO
  118. Enables code in the dsp module to avoid floating point denormals during the
  119. processing of some of the dsp module's filters.
  120. Enabling this will add a slight performance overhead to the DSP module's
  121. filters and algorithms. If your audio app already disables denormals altogether
  122. (for example, by using the ScopedNoDenormals class or the
  123. FloatVectorOperations::disableDenormalisedNumberSupport method), then you
  124. can safely disable this flag to shave off a few cpu cycles from the DSP module's
  125. filters and algorithms.
  126. */
  127. #ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO
  128. #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1
  129. #endif
  130. //==============================================================================
  131. #undef Complex // apparently some C libraries actually define these symbols (!)
  132. #undef Factor
  133. #undef check
  134. namespace juce
  135. {
  136. namespace dsp
  137. {
  138. template <typename Type>
  139. using Complex = std::complex<Type>;
  140. //==============================================================================
  141. namespace util
  142. {
  143. /** Use this function to prevent denormals on intel CPUs.
  144. This function will work with both primitives and simple containers.
  145. */
  146. #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
  147. inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  148. #ifndef DOXYGEN
  149. inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  150. inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); }
  151. #endif
  152. #else
  153. inline void snapToZero (float& x) noexcept { ignoreUnused (x); }
  154. #ifndef DOXYGEN
  155. inline void snapToZero (double& x) noexcept { ignoreUnused (x); }
  156. inline void snapToZero (long double& x) noexcept { ignoreUnused (x); }
  157. #endif
  158. #endif
  159. }
  160. }
  161. }
  162. //==============================================================================
  163. #if JUCE_USE_SIMD
  164. #include "native/juce_fallback_SIMDNativeOps.h"
  165. // include the correct native file for this build target CPU
  166. #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86)
  167. #ifdef __AVX2__
  168. #include "native/juce_avx_SIMDNativeOps.h"
  169. #else
  170. #include "native/juce_sse_SIMDNativeOps.h"
  171. #endif
  172. #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__)
  173. #include "native/juce_neon_SIMDNativeOps.h"
  174. #else
  175. #error "SIMD register support not implemented for this platform"
  176. #endif
  177. #include "containers/juce_SIMDRegister.h"
  178. #endif
  179. #include "maths/juce_SpecialFunctions.h"
  180. #include "maths/juce_Matrix.h"
  181. #include "maths/juce_Phase.h"
  182. #include "maths/juce_Polynomial.h"
  183. #include "maths/juce_FastMathApproximations.h"
  184. #include "maths/juce_LookupTable.h"
  185. #include "maths/juce_LogRampedValue.h"
  186. #include "containers/juce_AudioBlock.h"
  187. #include "processors/juce_ProcessContext.h"
  188. #include "processors/juce_ProcessorWrapper.h"
  189. #include "processors/juce_ProcessorChain.h"
  190. #include "processors/juce_ProcessorDuplicator.h"
  191. #include "processors/juce_Bias.h"
  192. #include "processors/juce_Gain.h"
  193. #include "processors/juce_WaveShaper.h"
  194. #include "processors/juce_IIRFilter.h"
  195. #include "processors/juce_FIRFilter.h"
  196. #include "processors/juce_Oscillator.h"
  197. #include "processors/juce_LadderFilter.h"
  198. #include "processors/juce_StateVariableFilter.h"
  199. #include "processors/juce_Oversampling.h"
  200. #include "processors/juce_Reverb.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"