40template <
typename FloatType>
44 Bias()
noexcept =
default;
52 jassert (newBias >=
static_cast<FloatType
> (-1) && newBias <=
static_cast<FloatType
> (1));
53 bias.setTargetValue (newBias);
60 FloatType
getBias() const noexcept {
return bias.getTargetValue(); }
65 if (! approximatelyEqual (rampDurationSeconds, newDurationSeconds))
67 rampDurationSeconds = newDurationSeconds;
72 double getRampDurationSeconds() const noexcept {
return rampDurationSeconds; }
78 sampleRate = spec.sampleRate;
84 bias.reset (sampleRate, rampDurationSeconds);
89 template <
typename SampleType>
92 return inputSample + bias.getNextValue();
97 template <
typename ProcessContext>
98 void process (
const ProcessContext& context)
noexcept
100 auto&& inBlock = context.getInputBlock();
101 auto&& outBlock = context.getOutputBlock();
103 jassert (inBlock.getNumChannels() == outBlock.getNumChannels());
104 jassert (inBlock.getNumSamples() == outBlock.getNumSamples());
106 auto len = inBlock.getNumSamples();
107 auto numChannels = inBlock.getNumChannels();
109 if (context.isBypassed)
111 bias.skip (
static_cast<int> (len));
113 if (context.usesSeparateInputAndOutputBlocks())
114 outBlock.copyFrom (inBlock);
119 if (numChannels == 1)
121 auto* src = inBlock.getChannelPointer (0);
122 auto* dst = outBlock.getChannelPointer (0);
124 for (
size_t i = 0; i < len; ++i)
125 dst[i] = src[i] + bias.getNextValue();
129 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386)
130 auto* biases =
static_cast<FloatType*
> (alloca (
sizeof (FloatType) * len));
132 for (
size_t i = 0; i < len; ++i)
133 biases[i] = bias.getNextValue();
135 for (
size_t chan = 0; chan < numChannels; ++chan)
136 FloatVectorOperations::add (outBlock.getChannelPointer (chan),
137 inBlock.getChannelPointer (chan),
138 biases,
static_cast<int> (len));
139 JUCE_END_IGNORE_WARNINGS_MSVC
147 double sampleRate = 0, rampDurationSeconds = 0;
149 void updateRamp() noexcept
152 bias.
reset (sampleRate, rampDurationSeconds);
void reset(double sampleRate, double rampLengthInSeconds) noexcept
SampleType processSample(SampleType inputSample) noexcept
FloatType getBias() const noexcept
void prepare(const ProcessSpec &spec) noexcept
void setRampDurationSeconds(double newDurationSeconds) noexcept
void setBias(FloatType newBias) noexcept
void process(const ProcessContext &context) noexcept