1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioBuffer: Remove approximatelyEqual

This commit is contained in:
Anthony Nicholls 2023-10-13 18:24:42 +01:00
parent 5e803ded5f
commit 04188c0e09

View file

@ -700,13 +700,9 @@ public:
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (! approximatelyEqual (gain, Type (1)) && ! isClear)
if (! isClear)
{
auto* d = channels[channel] + startSample;
if (approximatelyEqual (gain, Type()))
FloatVectorOperations::clear (d, numSamples);
else
FloatVectorOperations::multiply (d, gain, numSamples);
}
}
@ -741,12 +737,6 @@ public:
Type startGain, Type endGain) noexcept
{
if (! isClear)
{
if (approximatelyEqual (startGain, endGain))
{
applyGain (channel, startSample, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
@ -761,7 +751,6 @@ public:
}
}
}
}
/** Applies a range of gains to a region of all channels.
@ -812,7 +801,7 @@ public:
jassert (isPositiveAndBelow (sourceChannel, source.numChannels));
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
if (! approximatelyEqual (gainToApplyToSource, (Type) 0) && numSamples > 0 && ! source.isClear)
if (numSamples > 0 && ! source.isClear)
{
auto* d = channels[destChannel] + destStartSample;
auto* s = source.channels[sourceChannel] + sourceStartSample;
@ -822,18 +811,11 @@ public:
if (isClear)
{
isClear = false;
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::copyWithMultiply (d, s, gainToApplyToSource, numSamples);
else
FloatVectorOperations::copy (d, s, numSamples);
}
else
{
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::addWithMultiply (d, s, gainToApplyToSource, numSamples);
else
FloatVectorOperations::add (d, s, numSamples);
}
JUCE_END_IGNORE_WARNINGS_MSVC
@ -864,26 +846,16 @@ public:
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (! approximatelyEqual (gainToApplyToSource, Type()) && numSamples > 0)
{
auto* d = channels[destChannel] + destStartSample;
if (isClear)
{
isClear = false;
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::copyWithMultiply (d, source, gainToApplyToSource, numSamples);
else
FloatVectorOperations::copy (d, source, numSamples);
}
else
{
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::addWithMultiply (d, source, gainToApplyToSource, numSamples);
else
FloatVectorOperations::add (d, source, numSamples);
}
}
}
@ -912,12 +884,6 @@ public:
int numSamples,
Type startGain,
Type endGain) noexcept
{
if (approximatelyEqual (startGain, endGain))
{
addFrom (destChannel, destStartSample, source, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
@ -936,7 +902,6 @@ public:
}
}
}
}
/** Copies samples from another buffer to this one.
@ -1036,27 +1001,10 @@ public:
if (numSamples > 0)
{
auto* d = channels[destChannel] + destStartSample;
if (! approximatelyEqual (gain, Type (1)))
{
if (approximatelyEqual (gain, Type()))
{
if (! isClear)
FloatVectorOperations::clear (d, numSamples);
}
else
{
isClear = false;
FloatVectorOperations::copyWithMultiply (d, source, gain, numSamples);
}
}
else
{
isClear = false;
FloatVectorOperations::copy (d, source, numSamples);
}
}
}
/** Copies samples from an array of floats into one of the channels, applying a gain ramp.
@ -1084,12 +1032,6 @@ public:
int numSamples,
Type startGain,
Type endGain) noexcept
{
if (approximatelyEqual (startGain, endGain))
{
copyFrom (destChannel, destStartSample, source, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
@ -1108,7 +1050,6 @@ public:
}
}
}
}
/** Returns a Range indicating the lowest and highest sample values in a given section.