47 template <
typename FloatType>
51 Bias() noexcept =
default;
59 jassert (newBias >= static_cast<FloatType> (-1) && newBias <= static_cast<FloatType> (1));
72 if (rampDurationSeconds != newDurationSeconds)
74 rampDurationSeconds = newDurationSeconds;
79 double getRampDurationSeconds()
const noexcept {
return rampDurationSeconds; }
85 sampleRate = spec.sampleRate;
91 bias.
reset (sampleRate, rampDurationSeconds);
96 template <
typename SampleType>
104 template<
typename ProcessContext>
105 void process (
const ProcessContext& context) noexcept
107 auto&& inBlock = context.getInputBlock();
108 auto&& outBlock = context.getOutputBlock();
110 jassert (inBlock.getNumChannels() == outBlock.getNumChannels());
111 jassert (inBlock.getNumSamples() == outBlock.getNumSamples());
113 auto len = inBlock.getNumSamples();
114 auto numChannels = inBlock.getNumChannels();
116 if (context.isBypassed)
118 bias.
skip (static_cast<int> (len));
120 if (context.usesSeparateInputAndOutputBlocks())
121 outBlock.copyFrom (inBlock);
126 if (numChannels == 1)
128 auto* src = inBlock.getChannelPointer (0);
129 auto* dst = outBlock.getChannelPointer (0);
131 for (
size_t i = 0; i < len; ++i)
136 auto* biases =
static_cast<FloatType*
> (alloca (
sizeof (FloatType) * len));
138 for (
size_t i = 0; i < len; ++i)
141 for (
size_t chan = 0; chan < numChannels; ++chan)
143 inBlock.getChannelPointer (chan),
144 biases,
static_cast<int> (len));
152 double sampleRate = 0, rampDurationSeconds = 0;
154 void updateRamp() noexcept
157 bias.
reset (sampleRate, rampDurationSeconds);
FloatType getNextValue() noexcept
Compute the next value.
FloatType getTargetValue() const noexcept
Returns the target value towards which the smoothed value is currently moving.
static void JUCE_CALLTYPE add(float *dest, float amountToAdd, int numValues) noexcept
Adds a fixed value to the destination values.
void prepare(const ProcessSpec &spec) noexcept
Called before processing starts.
FloatType skip(int numSamples) noexcept
Skip the next numSamples samples.
FloatType getBias() const noexcept
Returns the DC bias.
void reset(double sampleRate, double rampLengthInSeconds) noexcept
Reset to a new sample rate and ramp length.
void setBias(FloatType newBias) noexcept
Sets the DC bias.
SampleType processSample(SampleType inputSample) const noexcept
Returns the result of processing a single sample.
void process(const ProcessContext &context) noexcept
Processes the input and output buffers supplied in the processing context.
void setRampDurationSeconds(double newDurationSeconds) noexcept
Sets the length of the ramp used for smoothing gain changes.
void setTargetValue(FloatType newValue) noexcept
Set the next value to ramp towards.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
Adds a DC offset (voltage bias) to the audio samples.