1.11
Classes | Public Member Functions | Static Public Member Functions | List of all members
SoundEffect Class Referencefinal

Notification Sound Effect. More...

#include <sound_effect.h>

Classes

class  SoundDevice
 The SoundDevice object is used to describe an ALSA PCM device. More...
 

Public Member Functions

 SoundEffect () noexcept
 SoundEffect default constructor.
 
 SoundEffect (const SoundEffect &)=delete
 
 SoundEffect (const std::string &uri, const SoundDevice &sound_device={})
 SoundEffect constructor.
 
 ~SoundEffect () noexcept
 
EGT_NODISCARD const SoundDevicedevice () const
 Return the sound device used.
 
bool device (const SoundDevice &sound_device) noexcept
 Set the sound device to use.
 
std::string media () const
 Return the uri of the sound file.
 
bool media (const std::string &uri) noexcept
 Set the uri of the sound file.
 
SoundEffectoperator= (const SoundEffect &)=delete
 
void play ()
 Start playing.
 
EGT_NODISCARD bool repeat () const
 Get the repeat status.
 
void repeat (bool value)
 Set the repeat status.
 
void stop ()
 Stop playing.
 

Static Public Member Functions

static std::vector< SoundDevicesound_device_list ()
 Get the list of the Alsa PCM devices with their card/device indexes and names.
 

Detailed Description

Notification Sound Effect.

The SoundEffect class is ideal for playing notification sounds, such as providing feedback when a button is clicked. This method is fast, asynchronous, and lightweight.

The stream control for Sound'effect is limited to starting and stopping, with an optional repeat feature.

Note
For more details about the SoundEffect class, please refer to the Audio page.

Constructor & Destructor Documentation

◆ SoundEffect() [1/3]

SoundEffect ( const std::string &  uri,
const SoundDevice sound_device = {} 
)
explicit

SoundEffect constructor.

Parameters
[in]uriThe uri of the sound file. Only file:// is accepted.
[in]sound_deviceThe sound device to use. Only the card index and device index are considered.

◆ SoundEffect() [2/3]

SoundEffect ( )
noexcept

SoundEffect default constructor.

Can be useful to set the uri or sound device later.

◆ SoundEffect() [3/3]

SoundEffect ( const SoundEffect )
delete

◆ ~SoundEffect()

~SoundEffect ( )
noexcept

Member Function Documentation

◆ device() [1/2]

EGT_NODISCARD const SoundDevice & device ( ) const

Return the sound device used.

◆ device() [2/2]

bool device ( const SoundDevice sound_device)
noexcept

Set the sound device to use.

Parameters
[in]sound_deviceThe sound device to use. Only the card index and device index are considered.
Returns
true on success, false otherwise.

◆ media() [1/2]

std::string media ( ) const

Return the uri of the sound file.

◆ media() [2/2]

bool media ( const std::string &  uri)
noexcept

Set the uri of the sound file.

Parameters
[in]uriThe uri of the sound file. Only file:// is accepted.
Returns
true on success, false otherwise.

◆ operator=()

SoundEffect & operator= ( const SoundEffect )
delete

◆ play()

void play ( )

Start playing.

◆ repeat() [1/2]

EGT_NODISCARD bool repeat ( ) const

Get the repeat status.

◆ repeat() [2/2]

void repeat ( bool  value)

Set the repeat status.

◆ sound_device_list()

static std::vector< SoundDevice > sound_device_list ( )
static

Get the list of the Alsa PCM devices with their card/device indexes and names.

◆ stop()

void stop ( )

Stop playing.