Async 1.8.0
Async::AudioCompressor Class Reference

A class to do audio compression/limiting. More...

#include <AsyncAudioCompressor.h>

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

Public Member Functions

 AudioCompressor (void)
 Default constuctor.
 
 ~AudioCompressor (void)
 Destructor.
 
void setThreshold (double thresh_db)
 Set the compression threshold.
 
void setRatio (double ratio)
 Set the compression ratio.
 
void setAttack (double attack_ms)
 Set the compressor attack time.
 
void setDecay (double decay_ms)
 Set the compressor decay time.
 
void setOutputGain (float gain)
 Set the output gain.
 
void reset (void)
 Reset the compressor.
 
- 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

virtual 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 to do audio compression/limiting.

Author
Tobias Blomberg / SM0SVX
Date
2006-05-01

Use this audio pipe class to do compression on an audio stream. Compression is a method to reduce the dynamic range of an audio signal. After it has been compressed it can be amplified to get a more audible end result.

This audio pipe component is mostly untested and is based on some ripped off code which I really have not checked how it performs or if it works at all...

Definition at line 169 of file AsyncAudioCompressor.h.

Constructor & Destructor Documentation

◆ AudioCompressor()

Async::AudioCompressor::AudioCompressor ( void )

Default constuctor.

◆ ~AudioCompressor()

Async::AudioCompressor::~AudioCompressor ( void )

Destructor.

Member Function Documentation

◆ processSamples()

virtual void Async::AudioCompressor::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 should be reimplemented by the inheriting 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::AudioCompressor::reset ( void )

Reset the compressor.

◆ setAttack()

void Async::AudioCompressor::setAttack ( double attack_ms)
inline

Set the compressor attack time.

Parameters
attack_msThe attack time in milliseconds

Definition at line 201 of file AsyncAudioCompressor.h.

References Async::EnvelopeDetector::setTc().

◆ setDecay()

void Async::AudioCompressor::setDecay ( double decay_ms)
inline

Set the compressor decay time.

Parameters
decay_msThe decay time in milliseconds

Definition at line 207 of file AsyncAudioCompressor.h.

References Async::EnvelopeDetector::setTc().

◆ setOutputGain()

void Async::AudioCompressor::setOutputGain ( float gain)

Set the output gain.

Parameters
gainThe gain to set.

The output gain is the amplification applied to the audio signal before it leaves the compressor. If gain > 1 the signal is amplified. If gain < 1 the signal is attenuated.

◆ setRatio()

void Async::AudioCompressor::setRatio ( double ratio)
inline

Set the compression ratio.

Parameters
ratioThe compression ratio (ex 0.1 == 10:1)

Definition at line 195 of file AsyncAudioCompressor.h.

◆ setThreshold()

void Async::AudioCompressor::setThreshold ( double thresh_db)
inline

Set the compression threshold.

Parameters
thresh_dbThe compression threshold in dB

The threshold is the level, in dB, the signal must rise to before the compressor kicks in.

Definition at line 189 of file AsyncAudioCompressor.h.


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