SuperpoweredSDK  v2.0.2
Superpowered Audio SDK
Superpowered::Filter Class Reference

Filter is an IIR filter based on the typical direct form 1 formula: y[n] = (b0/a0)*x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2] - (a1/a0)*y[n-1] - (a2/a0)*y[n-2] It doesn't allocate any internal buffers and needs just a few bytes of memory. More...

#include "SuperpoweredFilter.h"

Inheritance diagram for Superpowered::Filter:
Collaboration diagram for Superpowered::Filter:

Public Member Functions

 Filter (FilterType filterType, unsigned int samplerate)
 Constructor. More...
 
 ~Filter ()
 
bool process (float *input, float *output, unsigned int numberOfFrames)
 Processes interleaved stereo audio. More...
 
bool processMono (float *input, float *output, unsigned int numberOfFrames)
 Processes mono audio. More...
 
void setCustomCoefficients (float b0, float b1, float b2, float a1, float a2)
 For advanced use. More...
 

Public Attributes

float decibel
 Decibel gain value for shelving and parametric filters. Limit: -96 to 24. More...
 
bool enabled = false
 Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation. More...
 
float frequency
 Frequency in Hz. From 1 Hz to the half of the current sample rate. More...
 
float octave
 Width in octave for bandlimited and parametric filters. Limit: 0.05 to 5. More...
 
float resonance
 Resonance value for resonant filters. Resonance = Q / 10. Limit: 0.01 to 1. More...
 
unsigned int samplerate = 0
 Sample rate in Hz. More...
 
float slope
 Slope value for shelving filters. Limit: 0.001 to 1. More...
 
FilterType type
 Filter type. Changing the filter type often involves changing other parameters as well. Therefore in a real-time context change the parameters and the type in the same thread with the process() call. More...
 

Protected Member Functions

 Filter (const Filter &)
 
Filteroperator= (const Filter &)
 

Protected Attributes

filterInternals * internals
 

Detailed Description

Filter is an IIR filter based on the typical direct form 1 formula: y[n] = (b0/a0)*x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2] - (a1/a0)*y[n-1] - (a2/a0)*y[n-2] It doesn't allocate any internal buffers and needs just a few bytes of memory.

Constructor & Destructor Documentation

◆ Filter() [1/2]

Superpowered::Filter::Filter ( FilterType  filterType,
unsigned int  samplerate 
)

Constructor.

Enabled is false by default.

Parameters
filterTypeThe initial filter type.
samplerateThe initial sample rate in Hz.

◆ ~Filter()

Superpowered::Filter::~Filter ( )

◆ Filter() [2/2]

Superpowered::Filter::Filter ( const Filter )
protected

Member Function Documentation

◆ operator=()

Filter& Superpowered::Filter::operator= ( const Filter )
protected

◆ process()

bool Superpowered::Filter::process ( float *  input,
float *  output,
unsigned int  numberOfFrames 
)
virtual

Processes interleaved stereo audio.

Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage. You can change all properties on any thread, concurrently with process(). Do not call any method concurrently with process().

Returns
If process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, the contents of output are not changed.
Parameters
inputPointer to floating point numbers. 32-bit interleaved stereo input.
outputPointer to floating point numbers. 32-bit interleaved stereo output. Can point to the same location with input (in-place processing).
numberOfFramesNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.

Implements Superpowered::FX.

◆ processMono()

bool Superpowered::Filter::processMono ( float *  input,
float *  output,
unsigned int  numberOfFrames 
)

Processes mono audio.

Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage. You can change all properties on any thread, concurrently with process(). Do not call any method concurrently with process().

Returns
If process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, the contents of output are not changed.
Parameters
inputPointer to floating point numbers. 32-bit mono input.
outputPointer to floating point numbers. 32-bit mono output. Can point to the same location with input (in-place processing).
numberOfFramesNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.

◆ setCustomCoefficients()

void Superpowered::Filter::setCustomCoefficients ( float  b0,
float  b1,
float  b2,
float  a1,
float  a2 
)

For advanced use.

Set custom coefficients for the filter. Changes will be smoothly handled to prevent audio artifacts. Do not call this concurrently with process().

Parameters
b0b0/a0
b1b1/a0
b2b2/a0
a1a1/a0
a2a2/a0

Member Data Documentation

◆ decibel

float Superpowered::Filter::decibel

Decibel gain value for shelving and parametric filters. Limit: -96 to 24.

◆ enabled

bool Superpowered::FX::enabled = false
inherited

Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.

◆ frequency

float Superpowered::Filter::frequency

Frequency in Hz. From 1 Hz to the half of the current sample rate.

◆ internals

filterInternals* Superpowered::Filter::internals
protected

◆ octave

float Superpowered::Filter::octave

Width in octave for bandlimited and parametric filters. Limit: 0.05 to 5.

◆ resonance

float Superpowered::Filter::resonance

Resonance value for resonant filters. Resonance = Q / 10. Limit: 0.01 to 1.

◆ samplerate

unsigned int Superpowered::FX::samplerate = 0
inherited

Sample rate in Hz.

◆ slope

float Superpowered::Filter::slope

Slope value for shelving filters. Limit: 0.001 to 1.

◆ type

FilterType Superpowered::Filter::type

Filter type. Changing the filter type often involves changing other parameters as well. Therefore in a real-time context change the parameters and the type in the same thread with the process() call.


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