The small3d library
Classes | Public Member Functions | List of all members
small3d::Sound Class Reference

Class that loads and plays a sound from an ogg file, or a native sound file. In the latter case, the file loaded has to have been produced by converting an .ogg file to a small3d native binary file using the format converter program, s3dfc, produced by this project's build scripts, for example by running s3dfc engine.ogg engine.bin (this would convert an engine sound .ogg file to a native binary sound file) ATTENTION: Unfortunately the native binary files have issues across architectures. So for example binaries created on Windows do not work on Linux. They need to be created and tested separately for each. More...

#include <Sound.hpp>

Public Member Functions

 Sound ()
 Default constructor.
 
 Sound (const std::string &soundFilePath)
 Ogg file loading constructor. More...
 
 ~Sound ()
 Destructor.
 
void play (const bool repeat=false)
 Play the sound. More...
 
void stop ()
 Stop playing the sound.
 
void divideVolume (uint32_t divisor)
 Divide the volume (in order to lower it). More...
 
 Sound (const Sound &other)
 Copy constructor.
 
 Sound (const Sound &&other)
 Move constructor.
 
Soundoperator= (const Sound &other)
 Copy assignment.
 
Soundoperator= (const Sound &&other)
 Move assignment.
 
void saveBinary (const std::string &binaryFilePath)
 Save sound data in binary format. More...
 

Detailed Description

Class that loads and plays a sound from an ogg file, or a native sound file. In the latter case, the file loaded has to have been produced by converting an .ogg file to a small3d native binary file using the format converter program, s3dfc, produced by this project's build scripts, for example by running s3dfc engine.ogg engine.bin (this would convert an engine sound .ogg file to a native binary sound file) ATTENTION: Unfortunately the native binary files have issues across architectures. So for example binaries created on Windows do not work on Linux. They need to be created and tested separately for each.

Constructor & Destructor Documentation

◆ Sound()

small3d::Sound::Sound ( const std::string &  soundFilePath)
explicit

Ogg file loading constructor.

Parameters
soundFilePathThe path to the ogg file from which to load the sound.

Member Function Documentation

◆ divideVolume()

void small3d::Sound::divideVolume ( uint32_t  divisor)

Divide the volume (in order to lower it).

Parameters
divisorNumber to divide the volume by.

◆ play()

void small3d::Sound::play ( const bool  repeat = false)

Play the sound.

Parameters
repeatRepeat the sound after it ends?

◆ saveBinary()

void small3d::Sound::saveBinary ( const std::string &  binaryFilePath)

Save sound data in binary format.

Parameters
binaryFilePathPath of file to save binary data to.

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