Async 1.7.0
|
A class to add gaussian white noise to an audio stream. More...
#include <AsyncAudioNoiseAdder.h>
Public Member Functions | |
AudioNoiseAdder (float level_db) | |
Constuctor. | |
~AudioNoiseAdder (void) | |
Destructor. | |
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. | |
AudioSource * | source (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. | |
AudioSink * | sink (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. | |
AudioSink * | handler (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. | |
AudioSource * | handler (void) const |
void | clearHandler (void) |
Clear a handler that was previously setup with setHandler. |
A class to add gaussian white noise to an audio stream.
This class implement a noise generator that add white gaussian noise to an audio stream. The noise is generated using the Box-Muller transform which for example is described on Wikipedia:
http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
The class is not implemented as a pure audio source but rather as an audio pipe component that should be inserted in the audio path.
Definition at line 121 of file AsyncAudioNoiseAdder.h.
Async::AudioNoiseAdder::AudioNoiseAdder | ( | float | level_db | ) |
Constuctor.
level_db | The noise level in dB |
The level_db parameter deserve some clarification. A level of 0dB give the same power as in a full scale sine wave. This make it possible to add noise to a generated signal under controlled conditions. For example, if a sine wave is generated in SvxLink with a level of 0dB and noise is added with a level of -10dB, we get a signal to noise ratio (SNR) of 10dB.
Referenced by processSamples().
Async::AudioNoiseAdder::~AudioNoiseAdder | ( | void | ) |
Destructor.
|
protectedvirtual |
Process incoming samples and put them into the output buffer.
dest | Destination buffer |
src | Source buffer |
count | Number 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.
References AudioNoiseAdder().