mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added an AudioBlock::multiply() overload for LinearSmoothedValue
This commit is contained in:
parent
315fb7cdc7
commit
f71df8704a
1 changed files with 47 additions and 0 deletions
|
|
@ -440,6 +440,52 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Multiplies all channels of the AudioBlock by a smoothly changing value and stores them . */
|
||||||
|
AudioBlock& multiply (LinearSmoothedValue<SampleType>& value) noexcept
|
||||||
|
{
|
||||||
|
if (! value.isSmoothing())
|
||||||
|
{
|
||||||
|
*this *= value.getTargetValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < numSamples; ++i)
|
||||||
|
{
|
||||||
|
const auto scaler = value.getNextValue();
|
||||||
|
|
||||||
|
for (size_t ch = 0; ch < numChannels; ++ch)
|
||||||
|
channelPtr (ch)[i] *= scaler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Multiplies all channels of the source by a smoothly changing value and stores them in the receiver. */
|
||||||
|
AudioBlock& multiply (AudioBlock src, LinearSmoothedValue<SampleType>& value) noexcept
|
||||||
|
{
|
||||||
|
jassert (numChannels == src.numChannels);
|
||||||
|
|
||||||
|
if (! value.isSmoothing())
|
||||||
|
{
|
||||||
|
copy (src);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto n = static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
const auto scaler = value.getNextValue();
|
||||||
|
|
||||||
|
for (size_t ch = 0; ch < numChannels; ++ch)
|
||||||
|
channelPtr (ch)[i] = scaler * src.getChannelPointer (ch)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Multiplies each value in src with factor and adds the result to the receiver. */
|
/** Multiplies each value in src with factor and adds the result to the receiver. */
|
||||||
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE addWithMultiply (AudioBlock src, SampleType factor) noexcept
|
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE addWithMultiply (AudioBlock src, SampleType factor) noexcept
|
||||||
{
|
{
|
||||||
|
|
@ -541,6 +587,7 @@ public:
|
||||||
forcedinline AudioBlock& operator-= (AudioBlock src) noexcept { return subtract (src); }
|
forcedinline AudioBlock& operator-= (AudioBlock src) noexcept { return subtract (src); }
|
||||||
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE operator*= (SampleType src) noexcept { return multiply (src); }
|
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE operator*= (SampleType src) noexcept { return multiply (src); }
|
||||||
forcedinline AudioBlock& operator*= (AudioBlock src) noexcept { return multiply (src); }
|
forcedinline AudioBlock& operator*= (AudioBlock src) noexcept { return multiply (src); }
|
||||||
|
forcedinline AudioBlock& operator*= (LinearSmoothedValue<SampleType>& value) noexcept { return multiply (value); }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// This class can only be used with floating point types
|
// This class can only be used with floating point types
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue