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

Efficient bandpass filter bank for real-time zero latency frequency analysis. Each band is a separated bandpass filter with custom width and center frequency. More...

#include "SuperpoweredBandpassFilterbank.h"

Public Member Functions

 BandpassFilterbank (unsigned int numBands, float *frequencies, float *widths, unsigned int samplerate, unsigned int numGroups=0)
 Constructor. More...
 
 ~BandpassFilterbank ()
 
float getAverageVolume ()
 Returns with the average volume of all audio passed to all previous process() or processNoAdd() calls. More...
 
float getPeakVolume ()
 Returns with the peak volume of all audio passed to all previous process() or processNoAdd() calls. More...
 
float getSumVolume ()
 Returns with the cumulated absolute value of all audio passed to all previous process() or processNoAdd() calls. Like you would add the absolute value of all audio samples together. More...
 
void process (float *input, unsigned int numberOfFrames, int group=0)
 Processes the audio. More...
 
void processNoAdd (float *input, unsigned int numberOfFrames, int group=0)
 Processes the audio. More...
 
void resetBands ()
 Sets all values of bands to 0. More...
 
void resetPeakVolume ()
 Resets the peak volume value to start measurement anew. More...
 
void resetSumAndAverageVolume ()
 Resets the sum and average volume value to start measurement anew. More...
 

Public Attributes

float * bands
 The magnitude of the frequency bands. Will be updated after each process() or processNoAdd() call. More...
 
unsigned int samplerate
 Sample rate in Hz. More...
 

Private Member Functions

 BandpassFilterbank (const BandpassFilterbank &)
 
BandpassFilterbankoperator= (const BandpassFilterbank &)
 

Private Attributes

bandpassFilterbankInternals * internals
 

Detailed Description

Efficient bandpass filter bank for real-time zero latency frequency analysis. Each band is a separated bandpass filter with custom width and center frequency.

Constructor & Destructor Documentation

◆ BandpassFilterbank() [1/2]

Superpowered::BandpassFilterbank::BandpassFilterbank ( unsigned int  numBands,
float *  frequencies,
float *  widths,
unsigned int  samplerate,
unsigned int  numGroups = 0 
)

Constructor.

Parameters
numBandsThe number of bands. Must be a multiply of 8.
frequenciesCenter frequencies of each band in Hz.
widthsWidths of each band in octave (1.0f is one octave, 1.0f / 12.0f is one halfnote).
samplerateThe initial sample rate in Hz.
numGroupsFor advanced use. The filter bank can be set up with multiple frequency + width groups, then process() or processNoAdd() can be performed with one specific frequency + width group. For example, set up one group with wide frequency coverage for the 20-20000 Hz range and three additional groups for 20-200 Hz, 200-2000 Hz and 2000-20000 Hz. When processing with the wide group of 20-20000 Hz and the highest magnitude can be found at 1000 Hz, use the 200-2000 Hz group for the next process() or processNoAdd() call, so the filter bank will have a "focus" on a narrower range. If numGroups > 0, then the number of frequencies and widths should be numGroups * numBands. Example: for numBands = 8 and numGroups = 2, provide 8 + 8 frequencies and 8 + 8 widths.

◆ ~BandpassFilterbank()

Superpowered::BandpassFilterbank::~BandpassFilterbank ( )

◆ BandpassFilterbank() [2/2]

Superpowered::BandpassFilterbank::BandpassFilterbank ( const BandpassFilterbank )
private

Member Function Documentation

◆ getAverageVolume()

float Superpowered::BandpassFilterbank::getAverageVolume ( )

Returns with the average volume of all audio passed to all previous process() or processNoAdd() calls.

◆ getPeakVolume()

float Superpowered::BandpassFilterbank::getPeakVolume ( )

Returns with the peak volume of all audio passed to all previous process() or processNoAdd() calls.

◆ getSumVolume()

float Superpowered::BandpassFilterbank::getSumVolume ( )

Returns with the cumulated absolute value of all audio passed to all previous process() or processNoAdd() calls. Like you would add the absolute value of all audio samples together.

◆ operator=()

BandpassFilterbank& Superpowered::BandpassFilterbank::operator= ( const BandpassFilterbank )
private

◆ process()

void Superpowered::BandpassFilterbank::process ( float *  input,
unsigned int  numberOfFrames,
int  group = 0 
)

Processes the audio.

It will ADD to the current magnitude in bands (like bands[0] += 0.123), so you can "measure" the magnitude of each frequency for a longer period of time. To calculate a result between 0 and 1 for multiple consecutive process() calls, divide each value in bands with the total number of frames passed to the consecutive process() calls.

Parameters
input32-bit interleaved stereo input buffer.
numberOfFramesNumber of frames to process.
groupThe group index for advanced "grouped" usage.

◆ processNoAdd()

void Superpowered::BandpassFilterbank::processNoAdd ( float *  input,
unsigned int  numberOfFrames,
int  group = 0 
)

Processes the audio.

It will replace the contents of bands.

Parameters
input32-bit interleaved stereo input buffer.
numberOfFramesNumber of frames to process.
groupThe group index for advanced "grouped" usage.

◆ resetBands()

void Superpowered::BandpassFilterbank::resetBands ( )

Sets all values of bands to 0.

◆ resetPeakVolume()

void Superpowered::BandpassFilterbank::resetPeakVolume ( )

Resets the peak volume value to start measurement anew.

◆ resetSumAndAverageVolume()

void Superpowered::BandpassFilterbank::resetSumAndAverageVolume ( )

Resets the sum and average volume value to start measurement anew.

Member Data Documentation

◆ bands

float* Superpowered::BandpassFilterbank::bands

The magnitude of the frequency bands. Will be updated after each process() or processNoAdd() call.

◆ internals

bandpassFilterbankInternals* Superpowered::BandpassFilterbank::internals
private

◆ samplerate

unsigned int Superpowered::BandpassFilterbank::samplerate

Sample rate in Hz.


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