47 template <
typename FloatType>
51 Bias() noexcept =
default;
59 jassert (newBias >=
static_cast<FloatType
> (-1) && newBias <=
static_cast<FloatType
> (1));
60 bias.setTargetValue (newBias);
67 FloatType
getBias() const noexcept {
return bias.getTargetValue(); }
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>
99 return inputSample + bias.getNextValue();
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)
132 dst[i] = src[i] + bias.getNextValue();
136 auto* biases =
static_cast<FloatType*
> (alloca (
sizeof (FloatType) * len));
138 for (
size_t i = 0; i < len; ++i)
139 biases[i] = bias.getNextValue();
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);
static void JUCE_CALLTYPE add(float *dest, float amountToAdd, int numValues) noexcept
Adds a fixed value to the destination values.
A utility class for values that need smoothing to avoid audio glitches.
void reset(double sampleRate, double rampLengthInSeconds) noexcept
Reset to a new sample rate and ramp length.
Adds a DC offset (voltage bias) to the audio samples.
FloatType getBias() const noexcept
Returns the DC bias.
void prepare(const ProcessSpec &spec) noexcept
Called before processing starts.
SampleType processSample(SampleType inputSample) const noexcept
Returns the result of processing a single sample.
void setRampDurationSeconds(double newDurationSeconds) noexcept
Sets the length of the ramp used for smoothing gain changes.
void setBias(FloatType newBias) noexcept
Sets the DC bias.
void process(const ProcessContext &context) noexcept
Processes the input and output buffers supplied in the processing context.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...