Async 1.8.0
|
A class for generating periodic audio signals. More...
#include <AsyncAudioGenerator.h>
Public Types | |
enum | Waveform { SIN , SQUARE , TRIANGLE } |
The type of waveform to generate. More... | |
Public Member Functions | |
AudioGenerator (Waveform wf=SIN) | |
Contructor. | |
~AudioGenerator (void) | |
Destructor. | |
void | setWaveform (Waveform wf) |
Set which waveform to use. | |
void | setFq (float tone_fq) |
Set the audio frequency. | |
void | setPower (float pwr_db) |
Set the power of the generated signal. | |
void | enable (bool enable) |
Enable or disable the generator. | |
void | resumeOutput (void) |
Resume audio output to the sink. | |
void | allSamplesFlushed (void) |
The registered sink has flushed all samples. | |
![]() | |
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 | |
![]() | |
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 for generating periodic audio signals.
This class is used to generate periodic audio signals. Note that audio samples will be produced in an endless loop until the connected sink stop the flow. This means that a sink have to be connected before enabling the generator or the application will get stuck. There also must be some form of flow control downstream in the audio pipe. One way to get flow control, if there are none naturally, is to use an Async::AudioPacer.
Definition at line 119 of file AsyncAudioGenerator.h.
The type of waveform to generate.
Enumerator | |
---|---|
SIN | Sine wave. |
SQUARE | Square wave. |
TRIANGLE | Triangular wave. |
Definition at line 125 of file AsyncAudioGenerator.h.
Contructor.
wf | The waveform to use ( |
Definition at line 135 of file AsyncAudioGenerator.h.
|
inline |
|
inlinevirtual |
The registered sink has flushed all samples.
This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
Definition at line 220 of file AsyncAudioGenerator.h.
|
inline |
Enable or disable the generator.
enable | Set to true to enable the generator or false to disable it |
Definition at line 188 of file AsyncAudioGenerator.h.
References enable(), and Async::AudioSource::sinkFlushSamples().
Referenced by enable(), and ~AudioGenerator().
|
inlinevirtual |
Resume audio output to the sink.
This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
Definition at line 207 of file AsyncAudioGenerator.h.
|
inline |
Set the audio frequency.
tone_fq | The frequency in Hz |
Definition at line 164 of file AsyncAudioGenerator.h.
|
inline |
Set the power of the generated signal.
pwr_db | The power of the signal in dBFS |
Use this function to set the power of the generated signal. 0dB power is defined as a full-scale sine wave.
Definition at line 177 of file AsyncAudioGenerator.h.
|
inline |
Set which waveform to use.
wf | The waveform to use ( |
Definition at line 154 of file AsyncAudioGenerator.h.