Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
AudioOutput Class Reference

Class for audio output. More...

#include <audiooutput.h>

Inheritance diagram for AudioOutput:
Inheritance graph
Collaboration diagram for AudioOutput:
Collaboration graph

Public Slots

void connectDevice (const bool active) override final
 Connect the audio output to a device (e.g. soundcard) with a given set of device parameters. More...
 

Signals

void onAudioDevicesAdded (const QStringList &devices)
 Signal indicating that a new audio device was plugged in (e.g. a USB headphone) More...
 
void onAudioDevicesRemoved (const QStringList &devices)
 Signal indicating that an audio device has been removed. More...
 
void onChangeOfAvailableAudioDevices (const QStringList &devices)
 Signal indicating that the list of available devices has been changed. More...
 
void onCurrentDeviceParametersChanged ()
 Signal indicating that the actually used audio device has changed. More...
 
void onConnectionSuccessfullyEstablished (bool success)
 Signal indicating that successful of failed connection. More...
 

Public Member Functions

 AudioOutput ()
 Constructor. More...
 
virtual bool init () override
 Init audio device. More...
 
virtual bool start () override
 Start audio device. More...
 
virtual bool stop () override
 Stop audio device. More...
 
virtual bool exit () override
 Exit audio device. More...
 
virtual void initiallyCalledWorker () override final
 Initially called worker function. More...
 
virtual void finallyCalledWorker () override final
 Virtual worker function called when the thread stops. More...
 
void setAudioGenerator (AudioGenerator &generator)
 Select an AudioGenerator for output. More...
 
AudioGeneratorgetAudioGenerator () const
 
void updateListOfDevices () override final
 Update the list of devices. More...
 
void setVolume (double volume)
 Set the global volume of the audio device. More...
 
void setActualParameters (const AudioParameters &p)
 Set audio device parameters (thread safe) More...
 
void setDefaultBufferSize (int n)
 
const AudioParameters getActualDeviceParameters () const
 Get the actual audio device parameters. More...
 
const AudioParameters getWantedDeviceParameters () const
 Get the intended audio device parameters. More...
 
void setWantedParameters (const AudioParameters &parameters)
 Set the wanted audio device parameters. More...
 
QStringList getListOfDevices () const
 Get the current list of devices from the last update. More...
 
virtual void suspend ()
 Mark the thread as suspended. More...
 
virtual void resume ()
 Resume from the suspend mode. More...
 
bool isActive () const
 Return true if thread is running and not suspended. More...
 
void setVerbosity (int verbosity)
 Set verbosity level of messages. More...
 
int getVerbosity ()
 Get verbosity level. More...
 
QString getThreadName () const
 Get thread name. More...
 

Protected Member Functions

virtual void periodicallyCalledWorker ()
 Virtual worker function called periodically from the timer. More...
 
void setPriority (const QThread::Priority p)
 Set thread priority. More...
 
void setTimerInterval (const int msec, const int firstMsec=0)
 Set timer interval for the periodically called worker. More...
 
void setThreadName (const QString name)
 Set thread name (Linux only) More...
 
bool isInterruptionRequested () const
 Return true if the thread was requested to interrupt or terminate. More...
 

Protected Attributes

int mDefaultBufferSize
 Default audio buffer size. More...
 
QStringList mAudioDeviceNames
 Current list of devices. More...
 

Private Attributes

AudioOutputDevice mAudioOutputDevice
 Instance of the device. More...
 
AudioGenerator defaultGenerator
 Default sine generator. More...
 
AudioGeneratorpAudioGenerator
 Pointer to synthesizer. More...
 
AudioDeviceGuard mAudioDeviceGuard
 Audio device guard. More...
 
QSettings mSettings
 Settings object. More...
 

Detailed Description

Class for audio output.

This is the principal class providing the user interface for audio output. It is derived from AudioBase which holds the device parameters and instantiates a private AudioOutputThread. The interface is activated by calling connect with the wanted parameters. Moreover, the class allows the user to connect an AudioGenerator (a sound-generating unit such as a synthesizer), passing this request to the AudioOutputThread.

Definition at line 45 of file audiooutput.h.

Constructor & Destructor Documentation

AudioOutput::AudioOutput ( )

Constructor.

The constructor connects the audio output with a default testtone generator.

Definition at line 35 of file audiooutput.cpp.

Here is the call graph for this function:

Member Function Documentation

void AudioOutput::connectDevice ( const bool  active)
finaloverrideslot

Connect the audio output to a device (e.g. soundcard) with a given set of device parameters.

The device parameters will be stored as mWantedDeviceParameters so that this information is available when entering the worker function run(). Moreover, the audio device thread is started with high priority.

Parameters
active: connect=true, disconnect=false
Note
This function does not return a boolean, indicating the success of the connection attempt, because the connection is running in an independent thread.

Definition at line 191 of file audiooutput.cpp.

Here is the call graph for this function:

bool AudioOutput::exit ( )
overridevirtual

Exit audio device.

Reimplemented from ThreadBase.

Definition at line 128 of file audiooutput.cpp.

Here is the call graph for this function:

void AudioOutput::finallyCalledWorker ( )
finaloverridevirtual

Virtual worker function called when the thread stops.

Reimplemented from ThreadBase.

Definition at line 101 of file audiooutput.cpp.

Here is the call graph for this function:

const AudioParameters AudioBase::getActualDeviceParameters ( ) const
inherited

Get the actual audio device parameters.

Get the actual audio device parameters (thread safe)

Returns
Copy of the audio device parameters

Definition at line 55 of file audiobase.cpp.

AudioGenerator* AudioOutput::getAudioGenerator ( ) const
inline

Definition at line 58 of file audiooutput.h.

Here is the call graph for this function:

QStringList AudioBase::getListOfDevices ( ) const
inlineinherited

Get the current list of devices from the last update.

Definition at line 70 of file audiobase.h.

Here is the call graph for this function:

QString ThreadBase::getThreadName ( ) const
inherited

Get thread name.

Definition at line 132 of file threadbase.cpp.

Here is the call graph for this function:

int ThreadBase::getVerbosity ( )
inlineinherited

Get verbosity level.

Definition at line 80 of file threadbase.h.

Here is the call graph for this function:

const AudioParameters AudioBase::getWantedDeviceParameters ( ) const
inherited

Get the intended audio device parameters.

Get the wanted audio device parameters (thread safe)

Returns
Copy of the audio device parameters

Definition at line 70 of file audiobase.cpp.

bool AudioOutput::init ( )
overridevirtual

Init audio device.

Reimplemented from ThreadBase.

Definition at line 54 of file audiooutput.cpp.

Here is the call graph for this function:

void AudioOutput::initiallyCalledWorker ( )
finaloverridevirtual

Initially called worker function.

Start the audio device and connect with the last set of parameters

Reimplemented from ThreadBase.

Definition at line 87 of file audiooutput.cpp.

Here is the call graph for this function:

bool ThreadBase::isActive ( ) const
inherited

Return true if thread is running and not suspended.

Definition at line 136 of file threadbase.cpp.

bool ThreadBase::isInterruptionRequested ( ) const
protectedinherited

Return true if the thread was requested to interrupt or terminate.

Definition at line 128 of file threadbase.cpp.

void AudioBase::onAudioDevicesAdded ( const QStringList &  devices)
signalinherited

Signal indicating that a new audio device was plugged in (e.g. a USB headphone)

void AudioBase::onAudioDevicesRemoved ( const QStringList &  devices)
signalinherited

Signal indicating that an audio device has been removed.

void AudioBase::onChangeOfAvailableAudioDevices ( const QStringList &  devices)
signalinherited

Signal indicating that the list of available devices has been changed.

void AudioBase::onConnectionSuccessfullyEstablished ( bool  success)
signalinherited

Signal indicating that successful of failed connection.

void AudioBase::onCurrentDeviceParametersChanged ( )
signalinherited

Signal indicating that the actually used audio device has changed.

virtual void ThreadBase::periodicallyCalledWorker ( )
inlineprotectedvirtualinherited

Virtual worker function called periodically from the timer.

Reimplemented in Tuner, and AudioDeviceGuard.

Definition at line 89 of file threadbase.h.

Here is the call graph for this function:

void ThreadBase::resume ( )
virtualinherited

Resume from the suspend mode.

Restart the timer and clear the mSuspended flag

Reimplemented in MidiPlayer.

Definition at line 99 of file threadbase.cpp.

void AudioOutput::setActualParameters ( const AudioParameters p)

Set audio device parameters (thread safe)

Set the audio parameters for the device, inform the AudioGenerator (the synthesizer) about the new parameter, and call a function that updates the GUI.

Definition at line 167 of file audiooutput.cpp.

Here is the call graph for this function:

void AudioOutput::setAudioGenerator ( AudioGenerator generator)

Select an AudioGenerator for output.

The AudioOutput can be connected with a sound-generating module subclassed from AudioGenerator. This is usually the synthesizer or the sampler in the application. Only one generator can be connected at a given time. Call this function to change the generator.

Parameters
generator: Reference to the AudioGenerator

Definition at line 148 of file audiooutput.cpp.

Here is the call graph for this function:

void AudioOutput::setDefaultBufferSize ( int  n)
inline

Definition at line 64 of file audiooutput.h.

Here is the call graph for this function:

void ThreadBase::setPriority ( const QThread::Priority  p)
protectedinherited

Set thread priority.

Definition at line 109 of file threadbase.cpp.

Here is the call graph for this function:

void ThreadBase::setThreadName ( const QString  name)
protectedinherited

Set thread name (Linux only)

Definition at line 121 of file threadbase.cpp.

Here is the call graph for this function:

void ThreadBase::setTimerInterval ( const int  msec,
const int  firstMsec = 0 
)
protectedinherited

Set timer interval for the periodically called worker.

Definition at line 117 of file threadbase.cpp.

Here is the call graph for this function:

void ThreadBase::setVerbosity ( int  verbosity)
inherited

Set verbosity level of messages.

Definition at line 113 of file threadbase.cpp.

Here is the call graph for this function:

void AudioOutput::setVolume ( double  volume)

Set the global volume of the audio device.

Parameters
volume: Volume between 0 and 1

Definition at line 285 of file audiooutput.cpp.

Here is the call graph for this function:

void AudioBase::setWantedParameters ( const AudioParameters parameters)
inherited

Set the wanted audio device parameters.

Set wanted audio device parameters (thread safe)

Parameters
parameters: Reference to the device parameters

Definition at line 100 of file audiobase.cpp.

bool AudioOutput::start ( )
overridevirtual

Start audio device.

Start the audio device and connect with the last set of parameters

Reimplemented from ThreadBase.

Definition at line 69 of file audiooutput.cpp.

Here is the call graph for this function:

bool AudioOutput::stop ( )
overridevirtual

Stop audio device.

Reimplemented from ThreadBase.

Definition at line 113 of file audiooutput.cpp.

Here is the call graph for this function:

void ThreadBase::suspend ( )
virtualinherited

Mark the thread as suspended.

Calling this function tells the thread that it has to wait in some sort of standby. Note that the thread itself is not terminated and that the event loop is still active. Calling this function stops the timer so that the periodicallyCalledWorker() is not active any more. In addition the mSuspended flag is set.

Reimplemented in MidiPlayer, and SoundGenerator.

Definition at line 84 of file threadbase.cpp.

void AudioOutput::updateListOfDevices ( )
finaloverridevirtual

Update the list of devices.

Implements AudioBase.

Definition at line 238 of file audiooutput.cpp.

Member Data Documentation

AudioGenerator AudioOutput::defaultGenerator
private

Default sine generator.

Definition at line 71 of file audiooutput.h.

AudioDeviceGuard AudioOutput::mAudioDeviceGuard
private

Audio device guard.

Definition at line 73 of file audiooutput.h.

QStringList AudioBase::mAudioDeviceNames
protectedinherited

Current list of devices.

Definition at line 94 of file audiobase.h.

AudioOutputDevice AudioOutput::mAudioOutputDevice
private

Instance of the device.

Definition at line 70 of file audiooutput.h.

int AudioOutput::mDefaultBufferSize
protected

Default audio buffer size.

Definition at line 77 of file audiooutput.h.

QSettings AudioOutput::mSettings
private

Settings object.

Definition at line 74 of file audiooutput.h.

AudioGenerator* AudioOutput::pAudioGenerator
private

Pointer to synthesizer.

Definition at line 72 of file audiooutput.h.


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