Browse Source

Made LinearSmoothedValue::skip() return the new current value

tags/2021-05-28
jules 7 years ago
parent
commit
2c3339ca1b
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h

+ 12
- 12
modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h View File

@@ -164,16 +164,16 @@ public:
{
if (buffer.getNumChannels() == 1)
{
FloatType* samples = buffer.getWritePointer(0);
auto samples = buffer.getWritePointer(0);
for (int i = 0; i < numSamples; i++)
for (int i = 0; i < numSamples; ++i)
samples[i] *= getNextValue();
}
else
{
for (int i = 0; i < numSamples; i++)
for (int i = 0; i < numSamples; ++i)
{
const FloatType gain = getNextValue();
auto gain = getNextValue();
for (int channel = 0; channel < buffer.getNumChannels(); channel++)
buffer.setSample (channel, i, buffer.getSample (channel, i) * gain);
@@ -188,22 +188,22 @@ public:
//==============================================================================
/** Skip the next numSamples samples.
This is identical to calling getNextValue numSamples times.
This is identical to calling getNextValue numSamples times. It returns
the new current value.
@see getNextValue
*/
void skip (int numSamples) noexcept
FloatType skip (int numSamples) noexcept
{
if (numSamples >= countdown)
{
currentValue = target;
countdown = 0;
return target;
}
else
{
currentValue += (step * static_cast<FloatType> (numSamples));
countdown -= numSamples;
}
currentValue += (step * static_cast<FloatType> (numSamples));
countdown -= numSamples;
return currentValue;
}
private:


Loading…
Cancel
Save