Audio plugin host https://kx.studio/carla
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.

133 lines
6.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_FLOATVECTOROPERATIONS_H_INCLUDED
  18. #define JUCE_FLOATVECTOROPERATIONS_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A collection of simple vector operations on arrays of floats, accelerated with
  22. SIMD instructions where possible.
  23. */
  24. class JUCE_API FloatVectorOperations
  25. {
  26. public:
  27. //==============================================================================
  28. /** Clears a vector of floats. */
  29. static void JUCE_CALLTYPE clear (float* dest, int numValues) noexcept;
  30. /** Clears a vector of doubles. */
  31. static void JUCE_CALLTYPE clear (double* dest, int numValues) noexcept;
  32. /** Copies a repeated value into a vector of floats. */
  33. static void JUCE_CALLTYPE fill (float* dest, float valueToFill, int numValues) noexcept;
  34. /** Copies a repeated value into a vector of doubles. */
  35. static void JUCE_CALLTYPE fill (double* dest, double valueToFill, int numValues) noexcept;
  36. /** Copies a vector of floats. */
  37. static void JUCE_CALLTYPE copy (float* dest, const float* src, int numValues) noexcept;
  38. /** Copies a vector of doubles. */
  39. static void JUCE_CALLTYPE copy (double* dest, const double* src, int numValues) noexcept;
  40. /** Copies a vector of floats, multiplying each value by a given multiplier */
  41. static void JUCE_CALLTYPE copyWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
  42. /** Copies a vector of doubles, multiplying each value by a given multiplier */
  43. static void JUCE_CALLTYPE copyWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
  44. /** Adds a fixed value to the destination values. */
  45. static void JUCE_CALLTYPE add (float* dest, float amountToAdd, int numValues) noexcept;
  46. /** Adds a fixed value to the destination values. */
  47. static void JUCE_CALLTYPE add (double* dest, double amountToAdd, int numValues) noexcept;
  48. /** Adds the source values to the destination values. */
  49. static void JUCE_CALLTYPE add (float* dest, const float* src, int numValues) noexcept;
  50. /** Adds the source values to the destination values. */
  51. static void JUCE_CALLTYPE add (double* dest, const double* src, int numValues) noexcept;
  52. /** Subtracts the source values from the destination values. */
  53. static void JUCE_CALLTYPE subtract (float* dest, const float* src, int numValues) noexcept;
  54. /** Subtracts the source values from the destination values. */
  55. static void JUCE_CALLTYPE subtract (double* dest, const double* src, int numValues) noexcept;
  56. /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
  57. static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
  58. /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
  59. static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
  60. /** Multiplies the destination values by the source values. */
  61. static void JUCE_CALLTYPE multiply (float* dest, const float* src, int numValues) noexcept;
  62. /** Multiplies the destination values by the source values. */
  63. static void JUCE_CALLTYPE multiply (double* dest, const double* src, int numValues) noexcept;
  64. /** Multiplies each of the destination values by a fixed multiplier. */
  65. static void JUCE_CALLTYPE multiply (float* dest, float multiplier, int numValues) noexcept;
  66. /** Multiplies each of the destination values by a fixed multiplier. */
  67. static void JUCE_CALLTYPE multiply (double* dest, double multiplier, int numValues) noexcept;
  68. /** Copies a source vector to a destination, negating each value. */
  69. static void JUCE_CALLTYPE negate (float* dest, const float* src, int numValues) noexcept;
  70. /** Copies a source vector to a destination, negating each value. */
  71. static void JUCE_CALLTYPE negate (double* dest, const double* src, int numValues) noexcept;
  72. /** Converts a stream of integers to floats, multiplying each one by the given multiplier. */
  73. static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int numValues) noexcept;
  74. /** Finds the miniumum and maximum values in the given array. */
  75. static Range<float> JUCE_CALLTYPE findMinAndMax (const float* src, int numValues) noexcept;
  76. /** Finds the miniumum and maximum values in the given array. */
  77. static Range<double> JUCE_CALLTYPE findMinAndMax (const double* src, int numValues) noexcept;
  78. /** Finds the miniumum value in the given array. */
  79. static float JUCE_CALLTYPE findMinimum (const float* src, int numValues) noexcept;
  80. /** Finds the miniumum value in the given array. */
  81. static double JUCE_CALLTYPE findMinimum (const double* src, int numValues) noexcept;
  82. /** Finds the maximum value in the given array. */
  83. static float JUCE_CALLTYPE findMaximum (const float* src, int numValues) noexcept;
  84. /** Finds the maximum value in the given array. */
  85. static double JUCE_CALLTYPE findMaximum (const double* src, int numValues) noexcept;
  86. /** On Intel CPUs, this method enables or disables the SSE flush-to-zero mode.
  87. Effectively, this is a wrapper around a call to _MM_SET_FLUSH_ZERO_MODE
  88. */
  89. static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
  90. };
  91. #endif // JUCE_FLOATVECTOROPERATIONS_H_INCLUDED