Async  1.5.0
Public Types | Public Member Functions | List of all members
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 }
 The type of waveform to generate. More...
 

Public Member Functions

 AudioGenerator (Waveform wf=SIN)
 Contructor. More...
 
 ~AudioGenerator (void)
 Destructor. More...
 
void setWaveform (Waveform wf)
 Set which waveform to use. More...
 
void setFq (double tone_fq)
 Set the audio frequency. More...
 
void setPower (float pwr_db)
 Set the power of the generated signal. More...
 
void enable (bool enable)
 Enable or disable the generator. More...
 
void resumeOutput (void)
 Resume audio output to the sink. More...
 
void allSamplesFlushed (void)
 The registered sink has flushed all samples. More...
 
- Public Member Functions inherited from Async::AudioSource
 AudioSource (void)
 Default constuctor. More...
 
virtual ~AudioSource (void)
 Destructor. More...
 
bool registerSink (AudioSink *sink, bool managed=false)
 Register an audio sink to provide samples to. More...
 
void unregisterSink (void)
 Unregister the previously registered audio sink. More...
 
bool isRegistered (void) const
 Check if an audio sink has been registered. More...
 
AudioSinksink (void) const
 Get the registered audio sink. More...
 
bool sinkManaged (void) const
 Check if the sink is managed or not. More...
 
void handleAllSamplesFlushed (void)
 The registered sink has flushed all samples. More...
 

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. More...
 
AudioSourcehandler (void) const
 
void clearHandler (void)
 Clear a handler that was previously setup with setHandler. More...
 

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.

Definition at line 117 of file AsyncAudioGenerator.h.

Member Enumeration Documentation

◆ Waveform

The type of waveform to generate.

Enumerator
SIN 

Sine wave.

SQUARE 

Square wave.

Definition at line 123 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 132 of file AsyncAudioGenerator.h.

◆ ~AudioGenerator()

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

Destructor.

Definition at line 141 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 207 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 183 of file AsyncAudioGenerator.h.

Referenced by ~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 197 of file AsyncAudioGenerator.h.

◆ setFq()

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

Set the audio frequency.

Parameters
tone_fqThe frequency in Hz

Definition at line 160 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 dB

Use this function to set the power of the generated signal. 0dB power is defined as a full-scale sine wave.

Definition at line 172 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 150 of file AsyncAudioGenerator.h.


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