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.

juce_FloatVectorOperations.h 8.6KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 a fixed value to each source value and stores it in the destination array. */
  49. static void JUCE_CALLTYPE add (float* dest, float* src, float amount, int numValues) noexcept;
  50. /** Adds a fixed value to each source value and stores it in the destination array. */
  51. static void JUCE_CALLTYPE add (double* dest, double* src, double amount, int numValues) noexcept;
  52. /** Adds the source values to the destination values. */
  53. static void JUCE_CALLTYPE add (float* dest, const float* src, int numValues) noexcept;
  54. /** Adds the source values to the destination values. */
  55. static void JUCE_CALLTYPE add (double* dest, const double* src, int numValues) noexcept;
  56. /** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
  57. static void JUCE_CALLTYPE add (float* dest, const float* src1, const float* src2, int num) noexcept;
  58. /** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
  59. static void JUCE_CALLTYPE add (double* dest, const double* src1, const double* src2, int num) noexcept;
  60. /** Subtracts the source values from the destination values. */
  61. static void JUCE_CALLTYPE subtract (float* dest, const float* src, int numValues) noexcept;
  62. /** Subtracts the source values from the destination values. */
  63. static void JUCE_CALLTYPE subtract (double* dest, const double* src, int numValues) noexcept;
  64. /** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
  65. static void JUCE_CALLTYPE subtract (float* dest, const float* src1, const float* src2, int num) noexcept;
  66. /** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
  67. static void JUCE_CALLTYPE subtract (double* dest, const double* src1, const double* src2, int num) noexcept;
  68. /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
  69. static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
  70. /** Multiplies each source value by the given multiplier, then adds it to the destination value. */
  71. static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
  72. /** Multiplies the destination values by the source values. */
  73. static void JUCE_CALLTYPE multiply (float* dest, const float* src, int numValues) noexcept;
  74. /** Multiplies the destination values by the source values. */
  75. static void JUCE_CALLTYPE multiply (double* dest, const double* src, int numValues) noexcept;
  76. /** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
  77. static void JUCE_CALLTYPE multiply (float* dest, const float* src1, const float* src2, int numValues) noexcept;
  78. /** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
  79. static void JUCE_CALLTYPE multiply (double* dest, const double* src1, const double* src2, int numValues) noexcept;
  80. /** Multiplies each of the destination values by a fixed multiplier. */
  81. static void JUCE_CALLTYPE multiply (float* dest, float multiplier, int numValues) noexcept;
  82. /** Multiplies each of the destination values by a fixed multiplier. */
  83. static void JUCE_CALLTYPE multiply (double* dest, double multiplier, int numValues) noexcept;
  84. /** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
  85. static void JUCE_CALLTYPE multiply (float* dest, const float* src, float multiplier, int num) noexcept;
  86. /** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
  87. static void JUCE_CALLTYPE multiply (double* dest, const double* src, double multiplier, int num) noexcept;
  88. /** Copies a source vector to a destination, negating each value. */
  89. static void JUCE_CALLTYPE negate (float* dest, const float* src, int numValues) noexcept;
  90. /** Copies a source vector to a destination, negating each value. */
  91. static void JUCE_CALLTYPE negate (double* dest, const double* src, int numValues) noexcept;
  92. /** Converts a stream of integers to floats, multiplying each one by the given multiplier. */
  93. static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int numValues) noexcept;
  94. /** Finds the miniumum and maximum values in the given array. */
  95. static Range<float> JUCE_CALLTYPE findMinAndMax (const float* src, int numValues) noexcept;
  96. /** Finds the miniumum and maximum values in the given array. */
  97. static Range<double> JUCE_CALLTYPE findMinAndMax (const double* src, int numValues) noexcept;
  98. /** Finds the miniumum value in the given array. */
  99. static float JUCE_CALLTYPE findMinimum (const float* src, int numValues) noexcept;
  100. /** Finds the miniumum value in the given array. */
  101. static double JUCE_CALLTYPE findMinimum (const double* src, int numValues) noexcept;
  102. /** Finds the maximum value in the given array. */
  103. static float JUCE_CALLTYPE findMaximum (const float* src, int numValues) noexcept;
  104. /** Finds the maximum value in the given array. */
  105. static double JUCE_CALLTYPE findMaximum (const double* src, int numValues) noexcept;
  106. /** On Intel CPUs, this method enables or disables the SSE flush-to-zero mode.
  107. Effectively, this is a wrapper around a call to _MM_SET_FLUSH_ZERO_MODE
  108. */
  109. static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
  110. };
  111. #endif // JUCE_FLOATVECTOROPERATIONS_H_INCLUDED