JUCE  v5.1.1-3-g1a0b28c73
JUCE API
Bias< FloatType > Class Template Reference

Adds a DC offset (voltage bias) to the audio samples. More...

#include <juce_Bias.h>

Collaboration diagram for Bias< FloatType >:

Public Member Functions

 Bias () noexcept
 
FloatType getBias () const noexcept
 Returns the DC bias. More...
 
double getRampDurationSeconds () const noexcept
 
void prepare (const ProcessSpec &spec) noexcept
 Called before processing starts. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Processes the input and output buffers supplied in the processing context. More...
 
template<typename SampleType >
SampleType processSample (SampleType inputSample) const noexcept
 Returns the result of processing a single sample. More...
 
void reset () noexcept
 
void setBias (FloatType newBias) noexcept
 Sets the DC bias. More...
 
void setRampDurationSeconds (double newDurationSeconds) noexcept
 Sets the length of the ramp used for smoothing gain changes. More...
 

Private Member Functions

void updateRamp () noexcept
 

Private Attributes

LinearSmoothedValue< FloatType > bias
 
double rampDurationSeconds = 0
 
double sampleRate = 0
 

Detailed Description

template<typename FloatType>
class Bias< FloatType >

Adds a DC offset (voltage bias) to the audio samples.

This is a useful preprocessor for asymmetric waveshaping when a waveshaper is bookended by a bias on input and a DC-offset removing high pass filter on output.

This is an extremely simple bias implementation that simply adds a value to a signal. More complicated bias behaviours exist in real circuits - for your homework ;).

Constructor & Destructor Documentation

◆ Bias()

template<typename FloatType >
Bias< FloatType >::Bias ( )
inlinenoexcept

Member Function Documentation

◆ getBias()

template<typename FloatType >
FloatType Bias< FloatType >::getBias ( ) const
inlinenoexcept

Returns the DC bias.

Returns
DC bias, which should be in the range [-1, 1]

References Bias< FloatType >::bias.

◆ getRampDurationSeconds()

template<typename FloatType >
double Bias< FloatType >::getRampDurationSeconds ( ) const
inlinenoexcept

◆ prepare()

template<typename FloatType >
void Bias< FloatType >::prepare ( const ProcessSpec spec)
inlinenoexcept

Called before processing starts.

References Bias< FloatType >::sampleRate, and Bias< FloatType >::updateRamp().

◆ process()

template<typename FloatType >
template<typename ProcessContext >
void Bias< FloatType >::process ( const ProcessContext context)
inlinenoexcept

Processes the input and output buffers supplied in the processing context.

References FloatVectorOperations::add(), Bias< FloatType >::bias, and jassert.

◆ processSample()

template<typename FloatType >
template<typename SampleType >
SampleType Bias< FloatType >::processSample ( SampleType  inputSample) const
inlinenoexcept

Returns the result of processing a single sample.

References Bias< FloatType >::bias.

◆ reset()

template<typename FloatType >
void Bias< FloatType >::reset ( )
inlinenoexcept

◆ setBias()

template<typename FloatType >
void Bias< FloatType >::setBias ( FloatType  newBias)
inlinenoexcept

Sets the DC bias.

Parameters
newBiasDC offset in range [-1, 1]

References Bias< FloatType >::bias, and jassert.

◆ setRampDurationSeconds()

template<typename FloatType >
void Bias< FloatType >::setRampDurationSeconds ( double  newDurationSeconds)
inlinenoexcept

Sets the length of the ramp used for smoothing gain changes.

References Bias< FloatType >::rampDurationSeconds, and Bias< FloatType >::updateRamp().

◆ updateRamp()

template<typename FloatType >
void Bias< FloatType >::updateRamp ( )
inlineprivatenoexcept

Member Data Documentation

◆ bias

◆ rampDurationSeconds

template<typename FloatType >
double Bias< FloatType >::rampDurationSeconds = 0
private

◆ sampleRate

template<typename FloatType >
double Bias< FloatType >::sampleRate = 0
private

The documentation for this class was generated from the following file: