libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Public Member Functions | List of all members
donut::audio::Sound Class Reference

Container for a particular sound wave that can be played in a SoundStage. More...

#include <donut/audio/Sound.hpp>

Public Member Functions

 Sound (const Filesystem &filesystem, const char *filepath, const SoundOptions &options={})
 Load a sound from a virtual file. More...
 
void * get () const noexcept
 Get an opaque handle to the internal representation of the sound. More...
 

Detailed Description

Container for a particular sound wave that can be played in a SoundStage.

A single loaded sound can be used to spawn multiple sound instances that play the same sound at different times or in parallel, and with potentially varying volumes, positions and velocities.

Constructor & Destructor Documentation

◆ Sound()

donut::audio::Sound::Sound ( const Filesystem filesystem,
const char *  filepath,
const SoundOptions options = {} 
)

Load a sound from a virtual file.

The supported file formats are:

  • Vorbis (.ogg)
  • RIFF (.wav)
  • FLAC (.flac)
  • MP3 (.mp3)
Parameters
filesystemvirtual filesystem to load the file from.
filepathvirtual filepath of the sound file to load.
optionssound options, see SoundOptions.
Exceptions
File::Erroron failure to open the file.
audio::Erroron failure to load a sound from the file.
std::bad_allocon allocation failure.
Note
The file format is determined entirely from the file contents; the filename extension is not taken into account.

Member Function Documentation

◆ get()

void* donut::audio::Sound::get ( ) const
inlinenoexcept

Get an opaque handle to the internal representation of the sound.

Returns
an untyped non-owning pointer to the internal representation of the sound.
Note
This function is used internally by the SoundStage implementation and is not intended to be used outside of it. The returned handle has no meaning to application code.

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