OpenShot Audio Library | OpenShotAudio: juce_FloatVectorOperations.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_FloatVectorOperations.h
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>
54 struct FloatVectorOperationsBase
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//==============================================================================
180 class 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//==============================================================================
218 class ScopedNoDenormals
219{
220public:
221 ScopedNoDenormals() noexcept;
222 ~ScopedNoDenormals() noexcept;
223
224private:
225 #if JUCE_USE_SSE_INTRINSICS || (JUCE_USE_ARM_NEON || (JUCE_64BIT && JUCE_ARM))
226 intptr_t fpsr;
227 #endif
228};
229
230} // namespace juce
juce::FloatVectorOperations
Definition juce_FloatVectorOperations.h:184
juce::Range
Definition juce_Range.h:40
juce::ScopedNoDenormals
Definition juce_FloatVectorOperations.h:219
juce::FloatVectorOperationsBase
Definition juce_FloatVectorOperations.h:55
juce::FloatVectorOperationsBase::add
static void JUCE_CALLTYPE add(FloatType *dest, FloatType amountToAdd, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1208
juce::FloatVectorOperationsBase::max
static void JUCE_CALLTYPE max(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1363
juce::FloatVectorOperationsBase::findMinimum
static FloatType JUCE_CALLTYPE findMinimum(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1398
juce::FloatVectorOperationsBase::multiply
static void JUCE_CALLTYPE multiply(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1295
juce::FloatVectorOperationsBase::clear
static void JUCE_CALLTYPE clear(FloatType *dest, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1176
juce::FloatVectorOperationsBase::addWithMultiply
static void JUCE_CALLTYPE addWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1259
juce::FloatVectorOperationsBase::findMinAndMax
static Range< FloatType > JUCE_CALLTYPE findMinAndMax(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1391
juce::FloatVectorOperationsBase::copy
static void JUCE_CALLTYPE copy(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1191
juce::FloatVectorOperationsBase::clip
static void JUCE_CALLTYPE clip(FloatType *dest, const FloatType *src, FloatType low, FloatType high, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1381
juce::FloatVectorOperationsBase::findMaximum
static FloatType JUCE_CALLTYPE findMaximum(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1405
juce::FloatVectorOperationsBase::subtractWithMultiply
static void JUCE_CALLTYPE subtractWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1277
juce::FloatVectorOperationsBase::copyWithMultiply
static void JUCE_CALLTYPE copyWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1199
juce::FloatVectorOperationsBase::fill
static void JUCE_CALLTYPE fill(FloatType *dest, FloatType valueToFill, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1183
juce::FloatVectorOperationsBase::subtract
static void JUCE_CALLTYPE subtract(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1242
juce::FloatVectorOperationsBase::abs
static void JUCE_CALLTYPE abs(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1337
juce::FloatVectorOperationsBase::negate
static void JUCE_CALLTYPE negate(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1329
juce::FloatVectorOperationsBase::min
static void JUCE_CALLTYPE min(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1345