JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_FloatVectorOperations.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26#ifndef JUCE_SNAP_TO_ZERO
27 #if JUCE_INTEL
28 #define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0;
29 #else
30 #define JUCE_SNAP_TO_ZERO(n) ignoreUnused (n)
31 #endif
32#endif
33class ScopedNoDenormals;
34
35//==============================================================================
53template <typename FloatType, typename CountType>
55{
57 static void JUCE_CALLTYPE clear (FloatType* dest, CountType numValues) noexcept;
58
60 static void JUCE_CALLTYPE fill (FloatType* dest, FloatType valueToFill, CountType numValues) noexcept;
61
63 static void JUCE_CALLTYPE copy (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
64
66 static void JUCE_CALLTYPE copyWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
67
69 static void JUCE_CALLTYPE add (FloatType* dest, FloatType amountToAdd, CountType numValues) noexcept;
70
72 static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, FloatType amount, CountType numValues) noexcept;
73
75 static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
76
78 static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
79
81 static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
82
84 static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
85
87 static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
88
90 static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
91
93 static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
94
96 static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
97
99 static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
100
102 static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType numValues) noexcept;
103
105 static void JUCE_CALLTYPE multiply (FloatType* dest, FloatType multiplier, CountType numValues) noexcept;
106
108 static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType num) noexcept;
109
111 static void JUCE_CALLTYPE negate (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
112
114 static void JUCE_CALLTYPE abs (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
115
117 static void JUCE_CALLTYPE min (FloatType* dest, const FloatType* src, FloatType comp, CountType num) noexcept;
118
120 static void JUCE_CALLTYPE min (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
121
123 static void JUCE_CALLTYPE max (FloatType* dest, const FloatType* src, FloatType comp, CountType num) noexcept;
124
126 static void JUCE_CALLTYPE max (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
127
129 static void JUCE_CALLTYPE clip (FloatType* dest, const FloatType* src, FloatType low, FloatType high, CountType num) noexcept;
130
132 static Range<FloatType> JUCE_CALLTYPE findMinAndMax (const FloatType* src, CountType numValues) noexcept;
133
135 static FloatType JUCE_CALLTYPE findMinimum (const FloatType* src, CountType numValues) noexcept;
136
138 static FloatType JUCE_CALLTYPE findMaximum (const FloatType* src, CountType numValues) noexcept;
139};
140
141#if ! DOXYGEN
142namespace detail
143{
144
145template <typename... Bases>
146struct NameForwarder : public Bases...
147{
148 using Bases::clear...,
149 Bases::fill...,
150 Bases::copy...,
151 Bases::copyWithMultiply...,
152 Bases::add...,
153 Bases::subtract...,
154 Bases::addWithMultiply...,
155 Bases::subtractWithMultiply...,
156 Bases::multiply...,
157 Bases::negate...,
158 Bases::abs...,
159 Bases::min...,
160 Bases::max...,
161 Bases::clip...,
162 Bases::findMinAndMax...,
163 Bases::findMinimum...,
164 Bases::findMaximum...;
165};
166
167} // namespace detail
168#endif
169
170//==============================================================================
180class JUCE_API FloatVectorOperations : public detail::NameForwarder<FloatVectorOperationsBase<float, int>,
181 FloatVectorOperationsBase<float, size_t>,
182 FloatVectorOperationsBase<double, int>,
183 FloatVectorOperationsBase<double, size_t>>
184{
185public:
186 static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int num) noexcept;
187
188 static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, size_t num) noexcept;
189
191 static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
192
199 static void JUCE_CALLTYPE disableDenormalisedNumberSupport (bool shouldDisable = true) noexcept;
200
202 static bool JUCE_CALLTYPE areDenormalsDisabled() noexcept;
203
204private:
205 friend ScopedNoDenormals;
206
207 static intptr_t JUCE_CALLTYPE getFpStatusRegister() noexcept;
208 static void JUCE_CALLTYPE setFpStatusRegister (intptr_t) noexcept;
209};
210
211//==============================================================================
219{
220public:
221 ScopedNoDenormals() noexcept;
222 ~ScopedNoDenormals() noexcept;
223
224private:
225 #if JUCE_USE_SSE_INTRINSICS || (JUCE_USE_ARM_NEON || (JUCE_64BIT && JUCE_ARM))
227 #endif
228};
229
230} // namespace juce
A collection of simple vector operations on arrays of floating point numbers, accelerated with SIMD i...
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
Helper class providing an RAII-based mechanism for temporarily disabling denormals on your CPU.
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
typedef intptr_t
A collection of simple vector operations on arrays of floating point numbers, accelerated with SIMD i...
static void JUCE_CALLTYPE add(FloatType *dest, FloatType amountToAdd, CountType numValues) noexcept
Adds a fixed value to the destination values.
static void JUCE_CALLTYPE max(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Each element of dest will be the maximum of the corresponding element of the source array and the giv...
static FloatType JUCE_CALLTYPE findMinimum(const FloatType *src, CountType numValues) noexcept
Finds the minimum value in the given array.
static void JUCE_CALLTYPE multiply(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Multiplies the destination values by the source values.
static void JUCE_CALLTYPE clear(FloatType *dest, CountType numValues) noexcept
Clears a vector of floating point numbers.
static void JUCE_CALLTYPE addWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Multiplies each source value by the given multiplier, then adds it to the destination value.
static Range< FloatType > JUCE_CALLTYPE findMinAndMax(const FloatType *src, CountType numValues) noexcept
Finds the minimum and maximum values in the given array.
static void JUCE_CALLTYPE copy(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Copies a vector of floating point numbers.
static void JUCE_CALLTYPE clip(FloatType *dest, const FloatType *src, FloatType low, FloatType high, CountType num) noexcept
Each element of dest is calculated by hard clipping the corresponding src element so that it is in th...
static FloatType JUCE_CALLTYPE findMaximum(const FloatType *src, CountType numValues) noexcept
Finds the maximum value in the given array.
static void JUCE_CALLTYPE subtractWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Multiplies each source value by the given multiplier, then subtracts it to the destination value.
static void JUCE_CALLTYPE copyWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Copies a vector of floating point numbers, multiplying each value by a given multiplier.
static void JUCE_CALLTYPE fill(FloatType *dest, FloatType valueToFill, CountType numValues) noexcept
Copies a repeated value into a vector of floating point numbers.
static void JUCE_CALLTYPE subtract(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Subtracts the source values from the destination values.
static void JUCE_CALLTYPE abs(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Copies a source vector to a destination, taking the absolute of each value.
static void JUCE_CALLTYPE negate(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Copies a source vector to a destination, negating each value.
static void JUCE_CALLTYPE min(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Each element of dest will be the minimum of the corresponding element of the source array and the giv...