1.10 |
Simple class to manage playing raw or WAV PCM sound files. More...
#include <sound.h>
Public Member Functions | |
Sound (const Sound &)=delete | |
Sound (const std::string &uri, const std::string &device="default") | |
Sound (const std::string &uri, unsigned int rate, int channels, const std::string &device="default") | |
Sound (Sound &&) noexcept | |
virtual | ~Sound () noexcept |
void | media (const std::string &uri) |
Sets the WAV file to play. | |
Sound & | operator= (const Sound &)=delete |
Sound & | operator= (Sound &&) noexcept |
void | play (bool repeat=false) |
Play the sound. | |
void | stop () |
Static Public Member Functions | |
static std::vector< std::string > | enumerate_pcm_devices () |
Enumerate PCM devices. | |
Protected Attributes | |
std::unique_ptr< detail::soundimpl > | m_impl |
Implementation pointer. | |
std::string | m_uri |
Sound file. | |
Simple class to manage playing raw or WAV PCM sound files.
The default sound card is used by default, but another one can be specified.
Another way to configure the default sound card is at the system level.
List available sound cards:
Then, add the following to /etc/asound.conf
|
explicit |
uri | The WAV file to play. |
device | ALSA sound device. |
|
explicit |
uri | The WAV file to play. |
rate | Rate of the sound file, i.e. 44100. |
channels | The number of channels in the sound file. |
device | ALSA sound device. |
|
virtualnoexcept |
|
static |
Enumerate PCM devices.
Enumerate PCM devices and fill the vector with their names. These names can be used for the device parameter of the constructors.
void media | ( | const std::string & | uri | ) |
Sets the WAV file to play.
uri | the WAV file URI |
void play | ( | bool | repeat = false | ) |
Play the sound.
This will immediately cancel any existing playback happening of this Sound.
repeat | Should the sound keep repeating? |
void stop | ( | ) |
|
protected |
Implementation pointer.
|
protected |
Sound file.