Async 1.8.0
Async::AudioFilter Class Reference

A class for creating a wide range of audio filters. More...

#include <AsyncAudioFilter.h>

Inheritance diagram for Async::AudioFilter:
Async::AudioProcessor Async::AudioSink Async::AudioSource

Public Member Functions

 AudioFilter (int sample_rate=INTERNAL_SAMPLE_RATE)
 Constuctor.
 
 AudioFilter (const std::string &filter_spec, int sample_rate=INTERNAL_SAMPLE_RATE)
 Constuctor.
 
 ~AudioFilter (void)
 Destructor.
 
bool parseFilterSpec (const std::string &filter_spec)
 Create the filter from the given filter specification.
 
std::string errorString (void) const
 Get the latest filter creation error.
 
void setOutputGain (float gain_db)
 Set the output gain of the filter.
 
void reset (void)
 Reset the filter state.
 
- Public Member Functions inherited from Async::AudioProcessor
 AudioProcessor (void)
 Default constuctor.
 
virtual ~AudioProcessor (void)
 Destructor.
 
int writeSamples (const float *samples, int len)
 Write audio to the filter.
 
void flushSamples (void)
 Order a flush of all samples.
 
void resumeOutput (void)
 Resume output to the sink if previously stopped.
 
void allSamplesFlushed (void)
 All samples have been flushed by the sink.
 
- Public Member Functions inherited from Async::AudioSink
 AudioSink (void)
 Default constuctor.
 
virtual ~AudioSink (void)
 Destructor.
 
bool registerSource (AudioSource *source)
 Register an audio source to provide samples to this sink.
 
void unregisterSource (void)
 Unregister the previously registered audio source.
 
bool isRegistered (void) const
 Check if an audio source has been registered.
 
AudioSourcesource (void) const
 Get the registered audio source.
 
- Public Member Functions inherited from Async::AudioSource
 AudioSource (void)
 Default constuctor.
 
virtual ~AudioSource (void)
 Destructor.
 
bool registerSink (AudioSink *sink, bool managed=false)
 Register an audio sink to provide samples to.
 
void unregisterSink (void)
 Unregister the previously registered audio sink.
 
bool isRegistered (void) const
 Check if an audio sink has been registered.
 
AudioSinksink (void) const
 Get the registered audio sink.
 
bool sinkManaged (void) const
 Check if the sink is managed or not.
 
void handleAllSamplesFlushed (void)
 The registered sink has flushed all samples.
 

Protected Member Functions

void processSamples (float *dest, const float *src, int count)
 Process incoming samples and put them into the output buffer.
 
- Protected Member Functions inherited from Async::AudioProcessor
void setInputOutputSampleRate (int input_rate, int output_rate)
 Set the input and output sample rates.
 
- Protected Member Functions inherited from Async::AudioSink
void sourceResumeOutput (void)
 Tell the source that we are ready to accept more samples.
 
void sourceAllSamplesFlushed (void)
 Tell the source that all samples have been flushed.
 
bool setHandler (AudioSink *handler)
 Setup another sink to handle the incoming audio.
 
void clearHandler (void)
 Clear a handler that was previously setup with setHandler.
 
AudioSinkhandler (void) const
 
- Protected Member Functions inherited from Async::AudioSource
int sinkWriteSamples (const float *samples, int len)
 
void sinkFlushSamples (void)
 
bool setHandler (AudioSource *handler)
 Setup another source to handle the outgoing audio.
 
AudioSourcehandler (void) const
 
void clearHandler (void)
 Clear a handler that was previously setup with setHandler.
 

Detailed Description

A class for creating a wide range of audio filters.

Author
Tobias Blomberg / SM0SVX
Date
2006-04-23

Definition at line 113 of file AsyncAudioFilter.h.

Constructor & Destructor Documentation

◆ AudioFilter() [1/2]

Async::AudioFilter::AudioFilter ( int sample_rate = INTERNAL_SAMPLE_RATE)
explicit

Constuctor.

Parameters
sample_rateThe sampling rate

◆ AudioFilter() [2/2]

Async::AudioFilter::AudioFilter ( const std::string & filter_spec,
int sample_rate = INTERNAL_SAMPLE_RATE )
explicit

Constuctor.

Parameters
filter_specThe filter specification
sample_rateThe sampling rate

Use this constructor to set up at filter and call parseFilterSpec on the given filter specification. If the filter creation fails, this function will do an "exit(1)".

◆ ~AudioFilter()

Async::AudioFilter::~AudioFilter ( void )

Destructor.

Member Function Documentation

◆ errorString()

std::string Async::AudioFilter::errorString ( void ) const
inline

Get the latest filter creation error.

Returns
Returns an error string if an error has occured previously

If the parseFilterSpec function return false, this function can be used to retrieve an error text describing the error.

Definition at line 158 of file AsyncAudioFilter.h.

◆ parseFilterSpec()

bool Async::AudioFilter::parseFilterSpec ( const std::string & filter_spec)

Create the filter from the given filter specification.

Parameters
filter_specThe filter specification
Returns
Returns true on success or else false

If using the constructor where a filter specification string is not given, use this function to set up the filter. This function may be called multiple times to change the filter without creating a new filter object.

◆ processSamples()

void Async::AudioFilter::processSamples ( float * dest,
const float * src,
int count )
protectedvirtual

Process incoming samples and put them into the output buffer.

Parameters
destDestination buffer
srcSource buffer
countNumber of samples in the source buffer

This function is called from the base class to do the actual processing of the incoming samples. All samples must be processed, otherwise they are lost and the output buffer will contain garbage.

Implements Async::AudioProcessor.

◆ reset()

void Async::AudioFilter::reset ( void )

Reset the filter state.

◆ setOutputGain()

void Async::AudioFilter::setOutputGain ( float gain_db)

Set the output gain of the filter.

Parameters
gain_dbThe gain to set in dB

Use this function to apply a gain (positive) or attenuation (negative) after the filter output. A gain of 6dB will amplify the signal with a factor of two.


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