dEngine
Simple 2D C++ game engine
Public Member Functions | Private Member Functions | Private Attributes | List of all members
dengine::Sound Class Reference

A Sound. More...

#include <Sound.h>

Public Member Functions

 Sound (std::string filepath)
 Constructor. More...
 
 ~Sound ()
 Destructor. More...
 
void LoadSound ()
 Loads sound into memory. More...
 
void PlaySound ()
 Plays the sound. More...
 
void StopSound ()
 Stops the sound from playing. More...
 

Private Member Functions

void SetupDevice ()
 

Private Attributes

std::string filePath
 
SDL_AudioDeviceID m_device
 
SDL_AudioSpec m_audioSpec
 
Uint8 * m_waveStart
 
Uint32 m_waveLength
 

Detailed Description

A Sound.

A sound is any audible event within the game, whether it be background music or a quick effect. Sounds are managed by the AudioManager and are loaded into and called from it.

See also
AudioManager

Constructor & Destructor Documentation

◆ Sound()

Sound::Sound ( std::string  filepath)

Constructor.

Create a new sound

Parameters
filepathThe filepath to a wav file

◆ ~Sound()

Sound::~Sound ( )

Destructor.

Frees up resources allocated by sound

Member Function Documentation

◆ LoadSound()

void Sound::LoadSound ( )

Loads sound into memory.

◆ PlaySound()

void Sound::PlaySound ( )

Plays the sound.

◆ SetupDevice()

void Sound::SetupDevice ( )
private

Referenced by LoadSound().

◆ StopSound()

void Sound::StopSound ( )

Stops the sound from playing.

Member Data Documentation

◆ filePath

std::string dengine::Sound::filePath
private

Path to the sound's wave file

Referenced by LoadSound(), and Sound().

◆ m_audioSpec

SDL_AudioSpec dengine::Sound::m_audioSpec
private

The details of the sound itself to play

Referenced by LoadSound(), and SetupDevice().

◆ m_device

SDL_AudioDeviceID dengine::Sound::m_device
private

Id of the audio device to initiate playback on

Referenced by PlaySound(), SetupDevice(), StopSound(), and ~Sound().

◆ m_waveLength

Uint32 dengine::Sound::m_waveLength
private

The length of the wave data

Referenced by LoadSound(), and PlaySound().

◆ m_waveStart

Uint8* dengine::Sound::m_waveStart
private

The start of the wave data

Referenced by LoadSound(), PlaySound(), and ~Sound().