migrating to the latest JUCE version
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,87 +1,99 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
AudioProcessLoadMeasurer::AudioProcessLoadMeasurer() = default;
|
||||
AudioProcessLoadMeasurer::~AudioProcessLoadMeasurer() = default;
|
||||
|
||||
void AudioProcessLoadMeasurer::reset()
|
||||
{
|
||||
reset (0, 0);
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::reset (double sampleRate, int blockSize)
|
||||
{
|
||||
cpuUsageProportion = 0;
|
||||
xruns = 0;
|
||||
|
||||
if (sampleRate > 0.0 && blockSize > 0)
|
||||
{
|
||||
msPerSample = 1000.0 / sampleRate;
|
||||
timeToCpuScale = (msPerSample > 0.0) ? (1.0 / msPerSample) : 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
msPerSample = 0;
|
||||
timeToCpuScale = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::registerBlockRenderTime (double milliseconds)
|
||||
{
|
||||
registerRenderTime (milliseconds, samplesPerBlock);
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::registerRenderTime (double milliseconds, int numSamples)
|
||||
{
|
||||
const auto maxMilliseconds = numSamples * msPerSample;
|
||||
const auto usedProportion = milliseconds / maxMilliseconds;
|
||||
const auto filterAmount = 0.2;
|
||||
cpuUsageProportion += filterAmount * (usedProportion - cpuUsageProportion);
|
||||
|
||||
if (milliseconds > maxMilliseconds)
|
||||
++xruns;
|
||||
}
|
||||
|
||||
double AudioProcessLoadMeasurer::getLoadAsProportion() const { return jlimit (0.0, 1.0, cpuUsageProportion); }
|
||||
double AudioProcessLoadMeasurer::getLoadAsPercentage() const { return 100.0 * getLoadAsProportion(); }
|
||||
|
||||
int AudioProcessLoadMeasurer::getXRunCount() const { return xruns; }
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p)
|
||||
: ScopedTimer (p, p.samplesPerBlock)
|
||||
{
|
||||
}
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p, int numSamplesInBlock)
|
||||
: owner (p), startTime (Time::getMillisecondCounterHiRes()), samplesInBlock (numSamplesInBlock)
|
||||
{
|
||||
}
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::~ScopedTimer()
|
||||
{
|
||||
owner.registerRenderTime (Time::getMillisecondCounterHiRes() - startTime, samplesInBlock);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2022 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
AudioProcessLoadMeasurer::AudioProcessLoadMeasurer() = default;
|
||||
AudioProcessLoadMeasurer::~AudioProcessLoadMeasurer() = default;
|
||||
|
||||
void AudioProcessLoadMeasurer::reset()
|
||||
{
|
||||
reset (0, 0);
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::reset (double sampleRate, int blockSize)
|
||||
{
|
||||
const SpinLock::ScopedLockType lock (mutex);
|
||||
|
||||
cpuUsageProportion = 0;
|
||||
xruns = 0;
|
||||
|
||||
samplesPerBlock = blockSize;
|
||||
msPerSample = (sampleRate > 0.0 && blockSize > 0) ? 1000.0 / sampleRate : 0;
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::registerBlockRenderTime (double milliseconds)
|
||||
{
|
||||
const SpinLock::ScopedTryLockType lock (mutex);
|
||||
|
||||
if (lock.isLocked())
|
||||
registerRenderTimeLocked (milliseconds, samplesPerBlock);
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::registerRenderTime (double milliseconds, int numSamples)
|
||||
{
|
||||
const SpinLock::ScopedTryLockType lock (mutex);
|
||||
|
||||
if (lock.isLocked())
|
||||
registerRenderTimeLocked (milliseconds, numSamples);
|
||||
}
|
||||
|
||||
void AudioProcessLoadMeasurer::registerRenderTimeLocked (double milliseconds, int numSamples)
|
||||
{
|
||||
if (msPerSample == 0)
|
||||
return;
|
||||
|
||||
const auto maxMilliseconds = numSamples * msPerSample;
|
||||
const auto usedProportion = milliseconds / maxMilliseconds;
|
||||
const auto filterAmount = 0.2;
|
||||
const auto proportion = cpuUsageProportion.load();
|
||||
cpuUsageProportion = proportion + filterAmount * (usedProportion - proportion);
|
||||
|
||||
if (milliseconds > maxMilliseconds)
|
||||
++xruns;
|
||||
}
|
||||
|
||||
double AudioProcessLoadMeasurer::getLoadAsProportion() const { return jlimit (0.0, 1.0, cpuUsageProportion.load()); }
|
||||
double AudioProcessLoadMeasurer::getLoadAsPercentage() const { return 100.0 * getLoadAsProportion(); }
|
||||
|
||||
int AudioProcessLoadMeasurer::getXRunCount() const { return xruns; }
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p)
|
||||
: ScopedTimer (p, p.samplesPerBlock)
|
||||
{
|
||||
}
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::ScopedTimer (AudioProcessLoadMeasurer& p, int numSamplesInBlock)
|
||||
: owner (p), startTime (Time::getMillisecondCounterHiRes()), samplesInBlock (numSamplesInBlock)
|
||||
{
|
||||
// numSamplesInBlock should never be zero. Did you remember to call AudioProcessLoadMeasurer::reset(),
|
||||
// passing the expected samples per block?
|
||||
jassert (numSamplesInBlock);
|
||||
}
|
||||
|
||||
AudioProcessLoadMeasurer::ScopedTimer::~ScopedTimer()
|
||||
{
|
||||
owner.registerRenderTime (Time::getMillisecondCounterHiRes() - startTime, samplesInBlock);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
@ -1,104 +1,109 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Maintains an ongoing measurement of the proportion of time which is being
|
||||
spent inside an audio callback.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioProcessLoadMeasurer
|
||||
{
|
||||
public:
|
||||
/** */
|
||||
AudioProcessLoadMeasurer();
|
||||
|
||||
/** Destructor. */
|
||||
~AudioProcessLoadMeasurer();
|
||||
|
||||
//==============================================================================
|
||||
/** Resets the state. */
|
||||
void reset();
|
||||
|
||||
/** Resets the counter, in preparation for use with the given sample rate and block size. */
|
||||
void reset (double sampleRate, int blockSize);
|
||||
|
||||
/** Returns the current load as a proportion 0 to 1.0 */
|
||||
double getLoadAsProportion() const;
|
||||
|
||||
/** Returns the current load as a percentage 0 to 100.0 */
|
||||
double getLoadAsPercentage() const;
|
||||
|
||||
/** Returns the number of over- (or under-) runs recorded since the state was reset. */
|
||||
int getXRunCount() const;
|
||||
|
||||
//==============================================================================
|
||||
/** This class measures the time between its construction and destruction and
|
||||
adds it to an AudioProcessLoadMeasurer.
|
||||
|
||||
e.g.
|
||||
@code
|
||||
{
|
||||
AudioProcessLoadMeasurer::ScopedTimer timer (myProcessLoadMeasurer);
|
||||
myCallback->doTheCallback();
|
||||
}
|
||||
@endcode
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
struct JUCE_API ScopedTimer
|
||||
{
|
||||
ScopedTimer (AudioProcessLoadMeasurer&);
|
||||
ScopedTimer (AudioProcessLoadMeasurer&, int numSamplesInBlock);
|
||||
~ScopedTimer();
|
||||
|
||||
private:
|
||||
AudioProcessLoadMeasurer& owner;
|
||||
double startTime;
|
||||
int samplesInBlock;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (ScopedTimer)
|
||||
};
|
||||
|
||||
/** Can be called manually to add the time of a callback to the stats.
|
||||
Normally you probably would never call this - it's simpler and more robust to
|
||||
use a ScopedTimer to measure the time using an RAII pattern.
|
||||
*/
|
||||
void registerBlockRenderTime (double millisecondsTaken);
|
||||
|
||||
/** Can be called manually to add the time of a callback to the stats.
|
||||
Normally you probably would never call this - it's simpler and more robust to
|
||||
use a ScopedTimer to measure the time using an RAII pattern.
|
||||
*/
|
||||
void registerRenderTime (double millisecondsTaken, int numSamples);
|
||||
|
||||
private:
|
||||
double cpuUsageProportion = 0, timeToCpuScale = 0, msPerSample = 0;
|
||||
int xruns = 0, samplesPerBlock = 0;
|
||||
};
|
||||
|
||||
|
||||
} // namespace juce
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2022 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Maintains an ongoing measurement of the proportion of time which is being
|
||||
spent inside an audio callback.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioProcessLoadMeasurer
|
||||
{
|
||||
public:
|
||||
/** */
|
||||
AudioProcessLoadMeasurer();
|
||||
|
||||
/** Destructor. */
|
||||
~AudioProcessLoadMeasurer();
|
||||
|
||||
//==============================================================================
|
||||
/** Resets the state. */
|
||||
void reset();
|
||||
|
||||
/** Resets the counter, in preparation for use with the given sample rate and block size. */
|
||||
void reset (double sampleRate, int blockSize);
|
||||
|
||||
/** Returns the current load as a proportion 0 to 1.0 */
|
||||
double getLoadAsProportion() const;
|
||||
|
||||
/** Returns the current load as a percentage 0 to 100.0 */
|
||||
double getLoadAsPercentage() const;
|
||||
|
||||
/** Returns the number of over- (or under-) runs recorded since the state was reset. */
|
||||
int getXRunCount() const;
|
||||
|
||||
//==============================================================================
|
||||
/** This class measures the time between its construction and destruction and
|
||||
adds it to an AudioProcessLoadMeasurer.
|
||||
|
||||
e.g.
|
||||
@code
|
||||
{
|
||||
AudioProcessLoadMeasurer::ScopedTimer timer (myProcessLoadMeasurer);
|
||||
myCallback->doTheCallback();
|
||||
}
|
||||
@endcode
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
struct JUCE_API ScopedTimer
|
||||
{
|
||||
ScopedTimer (AudioProcessLoadMeasurer&);
|
||||
ScopedTimer (AudioProcessLoadMeasurer&, int numSamplesInBlock);
|
||||
~ScopedTimer();
|
||||
|
||||
private:
|
||||
AudioProcessLoadMeasurer& owner;
|
||||
double startTime;
|
||||
int samplesInBlock;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (ScopedTimer)
|
||||
};
|
||||
|
||||
/** Can be called manually to add the time of a callback to the stats.
|
||||
Normally you probably would never call this - it's simpler and more robust to
|
||||
use a ScopedTimer to measure the time using an RAII pattern.
|
||||
*/
|
||||
void registerBlockRenderTime (double millisecondsTaken);
|
||||
|
||||
/** Can be called manually to add the time of a callback to the stats.
|
||||
Normally you probably would never call this - it's simpler and more robust to
|
||||
use a ScopedTimer to measure the time using an RAII pattern.
|
||||
*/
|
||||
void registerRenderTime (double millisecondsTaken, int numSamples);
|
||||
|
||||
private:
|
||||
void registerRenderTimeLocked (double, int);
|
||||
|
||||
SpinLock mutex;
|
||||
int samplesPerBlock = 0;
|
||||
double msPerSample = 0;
|
||||
std::atomic<double> cpuUsageProportion { 0 };
|
||||
std::atomic<int> xruns { 0 };
|
||||
};
|
||||
|
||||
|
||||
} // namespace juce
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,257 +1,269 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#ifndef JUCE_SNAP_TO_ZERO
|
||||
#if JUCE_INTEL
|
||||
#define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0;
|
||||
#else
|
||||
#define JUCE_SNAP_TO_ZERO(n) ignoreUnused (n)
|
||||
#endif
|
||||
#endif
|
||||
class ScopedNoDenormals;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A collection of simple vector operations on arrays of floats, accelerated with
|
||||
SIMD instructions where possible.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API FloatVectorOperations
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Clears a vector of floats. */
|
||||
static void JUCE_CALLTYPE clear (float* dest, int numValues) noexcept;
|
||||
|
||||
/** Clears a vector of doubles. */
|
||||
static void JUCE_CALLTYPE clear (double* dest, int numValues) noexcept;
|
||||
|
||||
/** Copies a repeated value into a vector of floats. */
|
||||
static void JUCE_CALLTYPE fill (float* dest, float valueToFill, int numValues) noexcept;
|
||||
|
||||
/** Copies a repeated value into a vector of doubles. */
|
||||
static void JUCE_CALLTYPE fill (double* dest, double valueToFill, int numValues) noexcept;
|
||||
|
||||
/** Copies a vector of floats. */
|
||||
static void JUCE_CALLTYPE copy (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Copies a vector of doubles. */
|
||||
static void JUCE_CALLTYPE copy (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Copies a vector of floats, multiplying each value by a given multiplier */
|
||||
static void JUCE_CALLTYPE copyWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
|
||||
|
||||
/** Copies a vector of doubles, multiplying each value by a given multiplier */
|
||||
static void JUCE_CALLTYPE copyWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to the destination values. */
|
||||
static void JUCE_CALLTYPE add (float* dest, float amountToAdd, int numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to the destination values. */
|
||||
static void JUCE_CALLTYPE add (double* dest, double amountToAdd, int numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to each source value and stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE add (float* dest, const float* src, float amount, int numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to each source value and stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE add (double* dest, const double* src, double amount, int numValues) noexcept;
|
||||
|
||||
/** Adds the source values to the destination values. */
|
||||
static void JUCE_CALLTYPE add (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Adds the source values to the destination values. */
|
||||
static void JUCE_CALLTYPE add (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE add (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE add (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Subtracts the source values from the destination values. */
|
||||
static void JUCE_CALLTYPE subtract (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Subtracts the source values from the destination values. */
|
||||
static void JUCE_CALLTYPE subtract (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE subtract (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE subtract (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (float* dest, const float* src, float multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (double* dest, const double* src, double multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Multiplies the destination values by the source values. */
|
||||
static void JUCE_CALLTYPE multiply (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Multiplies the destination values by the source values. */
|
||||
static void JUCE_CALLTYPE multiply (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (float* dest, const float* src1, const float* src2, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (double* dest, const double* src1, const double* src2, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each of the destination values by a fixed multiplier. */
|
||||
static void JUCE_CALLTYPE multiply (float* dest, float multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each of the destination values by a fixed multiplier. */
|
||||
static void JUCE_CALLTYPE multiply (double* dest, double multiplier, int numValues) noexcept;
|
||||
|
||||
/** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (float* dest, const float* src, float multiplier, int num) noexcept;
|
||||
|
||||
/** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (double* dest, const double* src, double multiplier, int num) noexcept;
|
||||
|
||||
/** Copies a source vector to a destination, negating each value. */
|
||||
static void JUCE_CALLTYPE negate (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Copies a source vector to a destination, negating each value. */
|
||||
static void JUCE_CALLTYPE negate (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Copies a source vector to a destination, taking the absolute of each value. */
|
||||
static void JUCE_CALLTYPE abs (float* dest, const float* src, int numValues) noexcept;
|
||||
|
||||
/** Copies a source vector to a destination, taking the absolute of each value. */
|
||||
static void JUCE_CALLTYPE abs (double* dest, const double* src, int numValues) noexcept;
|
||||
|
||||
/** Converts a stream of integers to floats, multiplying each one by the given multiplier. */
|
||||
static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int numValues) noexcept;
|
||||
|
||||
/** Each element of dest will be the minimum of the corresponding element of the source array and the given comp value. */
|
||||
static void JUCE_CALLTYPE min (float* dest, const float* src, float comp, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the minimum of the corresponding element of the source array and the given comp value. */
|
||||
static void JUCE_CALLTYPE min (double* dest, const double* src, double comp, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the minimum of the corresponding source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE min (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the minimum of the corresponding source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE min (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the maximum of the corresponding element of the source array and the given comp value. */
|
||||
static void JUCE_CALLTYPE max (float* dest, const float* src, float comp, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the maximum of the corresponding element of the source array and the given comp value. */
|
||||
static void JUCE_CALLTYPE max (double* dest, const double* src, double comp, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the maximum of the corresponding source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE max (float* dest, const float* src1, const float* src2, int num) noexcept;
|
||||
|
||||
/** Each element of dest will be the maximum of the corresponding source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE max (double* dest, const double* src1, const double* src2, int num) noexcept;
|
||||
|
||||
/** Each element of dest is calculated by hard clipping the corresponding src element so that it is in the range specified by the arguments low and high. */
|
||||
static void JUCE_CALLTYPE clip (float* dest, const float* src, float low, float high, int num) noexcept;
|
||||
|
||||
/** Each element of dest is calculated by hard clipping the corresponding src element so that it is in the range specified by the arguments low and high. */
|
||||
static void JUCE_CALLTYPE clip (double* dest, const double* src, double low, double high, int num) noexcept;
|
||||
|
||||
/** Finds the minimum and maximum values in the given array. */
|
||||
static Range<float> JUCE_CALLTYPE findMinAndMax (const float* src, int numValues) noexcept;
|
||||
|
||||
/** Finds the minimum and maximum values in the given array. */
|
||||
static Range<double> JUCE_CALLTYPE findMinAndMax (const double* src, int numValues) noexcept;
|
||||
|
||||
/** Finds the minimum value in the given array. */
|
||||
static float JUCE_CALLTYPE findMinimum (const float* src, int numValues) noexcept;
|
||||
|
||||
/** Finds the minimum value in the given array. */
|
||||
static double JUCE_CALLTYPE findMinimum (const double* src, int numValues) noexcept;
|
||||
|
||||
/** Finds the maximum value in the given array. */
|
||||
static float JUCE_CALLTYPE findMaximum (const float* src, int numValues) noexcept;
|
||||
|
||||
/** Finds the maximum value in the given array. */
|
||||
static double JUCE_CALLTYPE findMaximum (const double* src, int numValues) noexcept;
|
||||
|
||||
/** This method enables or disables the SSE/NEON flush-to-zero mode. */
|
||||
static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
|
||||
|
||||
/** On Intel CPUs, this method enables the SSE flush-to-zero and denormalised-are-zero modes.
|
||||
This effectively sets the DAZ and FZ bits of the MXCSR register. On arm CPUs this will
|
||||
enable flush to zero mode.
|
||||
It's a convenient thing to call before audio processing code where you really want to
|
||||
avoid denormalisation performance hits.
|
||||
*/
|
||||
static void JUCE_CALLTYPE disableDenormalisedNumberSupport (bool shouldDisable = true) noexcept;
|
||||
|
||||
/** This method returns true if denormals are currently disabled. */
|
||||
static bool JUCE_CALLTYPE areDenormalsDisabled() noexcept;
|
||||
|
||||
private:
|
||||
friend ScopedNoDenormals;
|
||||
|
||||
static intptr_t JUCE_CALLTYPE getFpStatusRegister() noexcept;
|
||||
static void JUCE_CALLTYPE setFpStatusRegister (intptr_t) noexcept;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Helper class providing an RAII-based mechanism for temporarily disabling
|
||||
denormals on your CPU.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class ScopedNoDenormals
|
||||
{
|
||||
public:
|
||||
ScopedNoDenormals() noexcept;
|
||||
~ScopedNoDenormals() noexcept;
|
||||
|
||||
private:
|
||||
#if JUCE_USE_SSE_INTRINSICS || (JUCE_USE_ARM_NEON || defined (__arm64__) || defined (__aarch64__))
|
||||
intptr_t fpsr;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2022 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#ifndef JUCE_SNAP_TO_ZERO
|
||||
#if JUCE_INTEL
|
||||
#define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0;
|
||||
#else
|
||||
#define JUCE_SNAP_TO_ZERO(n) ignoreUnused (n)
|
||||
#endif
|
||||
#endif
|
||||
class ScopedNoDenormals;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A collection of simple vector operations on arrays of floating point numbers,
|
||||
accelerated with SIMD instructions where possible, usually accessed from
|
||||
the FloatVectorOperations class.
|
||||
|
||||
@code
|
||||
float data[64];
|
||||
|
||||
// The following two function calls are equivalent:
|
||||
FloatVectorOperationsBase<float, int>::clear (data, 64);
|
||||
FloatVectorOperations::clear (data, 64);
|
||||
@endcode
|
||||
|
||||
@see FloatVectorOperations
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
template <typename FloatType, typename CountType>
|
||||
struct FloatVectorOperationsBase
|
||||
{
|
||||
/** Clears a vector of floating point numbers. */
|
||||
static void JUCE_CALLTYPE clear (FloatType* dest, CountType numValues) noexcept;
|
||||
|
||||
/** Copies a repeated value into a vector of floating point numbers. */
|
||||
static void JUCE_CALLTYPE fill (FloatType* dest, FloatType valueToFill, CountType numValues) noexcept;
|
||||
|
||||
/** Copies a vector of floating point numbers. */
|
||||
static void JUCE_CALLTYPE copy (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Copies a vector of floating point numbers, multiplying each value by a given multiplier */
|
||||
static void JUCE_CALLTYPE copyWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to the destination values. */
|
||||
static void JUCE_CALLTYPE add (FloatType* dest, FloatType amountToAdd, CountType numValues) noexcept;
|
||||
|
||||
/** Adds a fixed value to each source value and stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, FloatType amount, CountType numValues) noexcept;
|
||||
|
||||
/** Adds the source values to the destination values. */
|
||||
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Adds each source1 value to the corresponding source2 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Subtracts the source values from the destination values. */
|
||||
static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Subtracts each source2 value from the corresponding source1 value and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then adds it to the destination value. */
|
||||
static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Multiplies each source value by the given multiplier, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the corresponding source2 value, then subtracts it to the destination value. */
|
||||
static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Multiplies the destination values by the source values. */
|
||||
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Multiplies each source1 value by the correspinding source2 value, then stores it in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType numValues) noexcept;
|
||||
|
||||
/** Multiplies each of the destination values by a fixed multiplier. */
|
||||
static void JUCE_CALLTYPE multiply (FloatType* dest, FloatType multiplier, CountType numValues) noexcept;
|
||||
|
||||
/** Multiplies each of the source values by a fixed multiplier and stores the result in the destination array. */
|
||||
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType num) noexcept;
|
||||
|
||||
/** Copies a source vector to a destination, negating each value. */
|
||||
static void JUCE_CALLTYPE negate (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 abs (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Each element of dest will be the minimum of the corresponding element of the source array and the given comp 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 source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE min (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Each element of dest will be the maximum of the corresponding element of the source array and the given comp value. */
|
||||
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 source1 and source2 values. */
|
||||
static void JUCE_CALLTYPE max (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
|
||||
|
||||
/** Each element of dest is calculated by hard clipping the corresponding src element so that it is in the range specified by the arguments low and high. */
|
||||
static void JUCE_CALLTYPE clip (FloatType* dest, const FloatType* src, FloatType low, FloatType high, CountType num) noexcept;
|
||||
|
||||
/** Finds the minimum and maximum values in the given array. */
|
||||
static Range<FloatType> JUCE_CALLTYPE findMinAndMax (const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Finds the minimum value in the given array. */
|
||||
static FloatType JUCE_CALLTYPE findMinimum (const FloatType* src, CountType numValues) noexcept;
|
||||
|
||||
/** Finds the maximum value in the given array. */
|
||||
static FloatType JUCE_CALLTYPE findMaximum (const FloatType* src, CountType numValues) noexcept;
|
||||
};
|
||||
|
||||
#if ! DOXYGEN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename...>
|
||||
struct NameForwarder;
|
||||
|
||||
template <typename Head>
|
||||
struct NameForwarder<Head> : Head {};
|
||||
|
||||
template <typename Head, typename... Tail>
|
||||
struct NameForwarder<Head, Tail...> : Head, NameForwarder<Tail...>
|
||||
{
|
||||
using Head::clear;
|
||||
using NameForwarder<Tail...>::clear;
|
||||
|
||||
using Head::fill;
|
||||
using NameForwarder<Tail...>::fill;
|
||||
|
||||
using Head::copy;
|
||||
using NameForwarder<Tail...>::copy;
|
||||
|
||||
using Head::copyWithMultiply;
|
||||
using NameForwarder<Tail...>::copyWithMultiply;
|
||||
|
||||
using Head::add;
|
||||
using NameForwarder<Tail...>::add;
|
||||
|
||||
using Head::subtract;
|
||||
using NameForwarder<Tail...>::subtract;
|
||||
|
||||
using Head::addWithMultiply;
|
||||
using NameForwarder<Tail...>::addWithMultiply;
|
||||
|
||||
using Head::subtractWithMultiply;
|
||||
using NameForwarder<Tail...>::subtractWithMultiply;
|
||||
|
||||
using Head::multiply;
|
||||
using NameForwarder<Tail...>::multiply;
|
||||
|
||||
using Head::negate;
|
||||
using NameForwarder<Tail...>::negate;
|
||||
|
||||
using Head::abs;
|
||||
using NameForwarder<Tail...>::abs;
|
||||
|
||||
using Head::min;
|
||||
using NameForwarder<Tail...>::min;
|
||||
|
||||
using Head::max;
|
||||
using NameForwarder<Tail...>::max;
|
||||
|
||||
using Head::clip;
|
||||
using NameForwarder<Tail...>::clip;
|
||||
|
||||
using Head::findMinAndMax;
|
||||
using NameForwarder<Tail...>::findMinAndMax;
|
||||
|
||||
using Head::findMinimum;
|
||||
using NameForwarder<Tail...>::findMinimum;
|
||||
|
||||
using Head::findMaximum;
|
||||
using NameForwarder<Tail...>::findMaximum;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A collection of simple vector operations on arrays of floating point numbers,
|
||||
accelerated with SIMD instructions where possible and providing all methods
|
||||
from FloatVectorOperationsBase.
|
||||
|
||||
@see FloatVectorOperationsBase
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API FloatVectorOperations : public detail::NameForwarder<FloatVectorOperationsBase<float, int>,
|
||||
FloatVectorOperationsBase<float, size_t>,
|
||||
FloatVectorOperationsBase<double, int>,
|
||||
FloatVectorOperationsBase<double, size_t>>
|
||||
{
|
||||
public:
|
||||
static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int num) noexcept;
|
||||
|
||||
static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, size_t num) noexcept;
|
||||
|
||||
/** This method enables or disables the SSE/NEON flush-to-zero mode. */
|
||||
static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
|
||||
|
||||
/** On Intel CPUs, this method enables the SSE flush-to-zero and denormalised-are-zero modes.
|
||||
This effectively sets the DAZ and FZ bits of the MXCSR register. On arm CPUs this will
|
||||
enable flush to zero mode.
|
||||
It's a convenient thing to call before audio processing code where you really want to
|
||||
avoid denormalisation performance hits.
|
||||
*/
|
||||
static void JUCE_CALLTYPE disableDenormalisedNumberSupport (bool shouldDisable = true) noexcept;
|
||||
|
||||
/** This method returns true if denormals are currently disabled. */
|
||||
static bool JUCE_CALLTYPE areDenormalsDisabled() noexcept;
|
||||
|
||||
private:
|
||||
friend ScopedNoDenormals;
|
||||
|
||||
static intptr_t JUCE_CALLTYPE getFpStatusRegister() noexcept;
|
||||
static void JUCE_CALLTYPE setFpStatusRegister (intptr_t) noexcept;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Helper class providing an RAII-based mechanism for temporarily disabling
|
||||
denormals on your CPU.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class ScopedNoDenormals
|
||||
{
|
||||
public:
|
||||
ScopedNoDenormals() noexcept;
|
||||
~ScopedNoDenormals() noexcept;
|
||||
|
||||
private:
|
||||
#if JUCE_USE_SSE_INTRINSICS || (JUCE_USE_ARM_NEON || defined (__arm64__) || defined (__aarch64__))
|
||||
intptr_t fpsr;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
|
Reference in New Issue
Block a user