Async 1.8.0
|
This class implements an audio delay line. More...
#include <AsyncAudioDelayLine.h>
Public Member Functions | |
AudioDelayLine (int length_ms) | |
Constuctor. | |
~AudioDelayLine (void) | |
Destructor. | |
void | setFadeTime (int time_ms) |
Set the fade in/out time when muting and clearing. | |
void | mute (bool do_mute, int time_ms=0) |
Mute audio. | |
void | clear (int time_ms=-1) |
Clear samples in the delay line. | |
int | writeSamples (const float *samples, int count) |
Write samples into the delay line. | |
void | flushSamples (void) |
Tell the sink to flush the previously written samples. | |
void | resumeOutput (void) |
Resume audio output to the sink. | |
void | allSamplesFlushed (void) |
The registered sink has flushed all samples. | |
![]() | |
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. | |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
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 |
![]() | |
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. | |
This class implements an audio delay line.
This class implements an audio delay line. It simply delays the audio with the specified amount of time. This can be useful if you want to mute audio based on a slow detector. With a delay line you have the possibility to mute audio that have passed the detector but have not yet passed through the delay line.
Definition at line 117 of file AsyncAudioDelayLine.h.
|
explicit |
Constuctor.
length_ms | The length in milliseconds of the delay line |
Async::AudioDelayLine::~AudioDelayLine | ( | void | ) |
Destructor.
|
virtual |
The registered sink has flushed all samples.
This function must be implemented by the inheriting class. It will be called when all samples have been flushed in the registered sink. This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
void Async::AudioDelayLine::clear | ( | int | time_ms = -1 | ) |
Clear samples in the delay line.
time_ms | How much time in milliseconds to clear |
Will clear the specified amount of samples in the delay line. If a clear is issued right before the delay line is flushed, the cleared samples will not be flushed. They will be thrown away.
|
virtual |
Tell the sink to flush the previously written samples.
This function is used to tell the sink to flush previously written samples. When done flushing, the sink should call the sourceAllSamplesFlushed function. This function is normally only called from a connected source object.
Reimplemented from Async::AudioSink.
void Async::AudioDelayLine::mute | ( | bool | do_mute, |
int | time_ms = 0 ) |
Mute audio.
do_mute | If true mute else unmute |
time_ms | How much more time in milliseconds to mute (see below) |
This function is used to mute audio in the delay line. With time_ms equal to zero its function is trivial. Mute incoming audio until mute is called with do_mute = false. The time_ms paramter specify how much time before (do_mute = true) or time after (do_mute = false) should be muted. Negative values are not allowed.
|
virtual |
Resume audio output to the sink.
This function must be reimplemented by the inheriting class. It will be called when the registered audio sink is ready to accept more samples. This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
void Async::AudioDelayLine::setFadeTime | ( | int | time_ms | ) |
Set the fade in/out time when muting and clearing.
time_ms | The time in milliseconds for the fade in/out |
When a mute or clear is issued the audio stream will not abruptly go to zero. Instead it will fade in and out smoothly to avoid popping sounds due to discontinueties in the sample stream. The default is 10 milliseconds. Set to 0 to turn off.
|
virtual |
Write samples into the delay line.
samples | The buffer containing the samples |
count | The number of samples in the buffer |
This function will write samples into the delay line. It's normally only called from a connected source object.
Reimplemented from Async::AudioSink.