Async 1.8.0
Async::AudioGenerator Class Reference

A class for generating periodic audio signals. More...

#include <AsyncAudioGenerator.h>

Inheritance diagram for Async::AudioGenerator:
Async::AudioSource

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.
 
- 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.
 

Additional Inherited Members

- 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 generating periodic audio signals.

Author
Tobias Blomberg / SM0SVX
Date
2015-09-28

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.

Examples
AsyncAudioIO_demo.cpp.

Definition at line 119 of file AsyncAudioGenerator.h.

Member Enumeration Documentation

◆ Waveform

The type of waveform to generate.

Enumerator
SIN 

Sine wave.

SQUARE 

Square wave.

TRIANGLE 

Triangular wave.

Definition at line 125 of file AsyncAudioGenerator.h.

Constructor & Destructor Documentation

◆ AudioGenerator()

Async::AudioGenerator::AudioGenerator ( Waveform wf = SIN)
inlineexplicit

Contructor.

Parameters
wfThe waveform to use (
See also
Waveform)

Definition at line 135 of file AsyncAudioGenerator.h.

◆ ~AudioGenerator()

Async::AudioGenerator::~AudioGenerator ( void )
inline

Destructor.

Definition at line 145 of file AsyncAudioGenerator.h.

References enable().

Member Function Documentation

◆ allSamplesFlushed()

void Async::AudioGenerator::allSamplesFlushed ( void )
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.

◆ enable()

void Async::AudioGenerator::enable ( bool enable)
inline

Enable or disable the generator.

Parameters
enableSet 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().

◆ resumeOutput()

void Async::AudioGenerator::resumeOutput ( void )
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.

◆ setFq()

void Async::AudioGenerator::setFq ( float tone_fq)
inline

Set the audio frequency.

Parameters
tone_fqThe frequency in Hz
Examples
AsyncAudioIO_demo.cpp.

Definition at line 164 of file AsyncAudioGenerator.h.

◆ setPower()

void Async::AudioGenerator::setPower ( float pwr_db)
inline

Set the power of the generated signal.

Parameters
pwr_dbThe 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.

◆ setWaveform()

void Async::AudioGenerator::setWaveform ( Waveform wf)
inline

Set which waveform to use.

Parameters
wfThe waveform to use (
See also
Waveform)

Definition at line 154 of file AsyncAudioGenerator.h.


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