Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Member Functions | Private Attributes | List of all members
AudioHandler Class Reference

The audio handler. More...

#include <AudioHandler.h>

Public Member Functions

 AudioHandler ()
 The constructor. More...
 
virtual ~AudioHandler ()
 The destructor. More...
 
void playMusic (const int times_)
 Plays the current music. More...
 
void playEffect (const int times_)
 Plays the current effect. More...
 
void stopMusic ()
 Stops playing the current music.
 
void setMusicVolume (const unsigned int percent_)
 Sets the volume for the music. More...
 
void setEffectVolume (const unsigned int percent_)
 Sets the volume for the effects. More...
 
void changeMusic (const std::string &path_)
 Changes current music. More...
 
void setCurrentMusic (const std::string &path_)
 Sets the current music. More...
 
void setCurrentEffect (const std::string &path_)
 Sets the current effect. More...
 

Private Attributes

Mix_Music * currentMusic
 The current music that is playing. More...
 
Mix_Chunk * currentEffect
 The current effect that is playing. More...
 

Detailed Description

The audio handler.

Class that handles all the audio in the game. Is a singleton, so should be called in each state.

Constructor & Destructor Documentation

AudioHandler::AudioHandler ( )

The constructor.

Initializes all the attributes.

AudioHandler::~AudioHandler ( )
virtual

The destructor.

Frees the allocated attributes.

Member Function Documentation

void AudioHandler::changeMusic ( const std::string &  path_)

Changes current music.

Stops the music, sets it, and plays it with infinite looping.

Parameters
path_: The path to the desired music.
void AudioHandler::playEffect ( const int  times_)

Plays the current effect.

Note
Will warn if there is no effect loaded.
Parameters
times_: Times to loop the song. MIX_LOOP (or -1) for infinite looping.
void AudioHandler::playMusic ( const int  times_)

Plays the current music.

Note
Will warn if there is no music loaded.
Parameters
times_: Times to loop the song. MIX_LOOP (or -1) for infinite looping.
void AudioHandler::setCurrentEffect ( const std::string &  path_)

Sets the current effect.

If one already exists, frees it first.

Parameters
path_: The path to the desired effect.
void AudioHandler::setCurrentMusic ( const std::string &  path_)

Sets the current music.

If one already exists, frees it first.

Parameters
path_: The path to the desired music.
void AudioHandler::setEffectVolume ( const unsigned int  percent_)

Sets the volume for the effects.

If the percent_ is over 100, will be set to 100.

Parameters
percent_: The volume percentage (0-100).
void AudioHandler::setMusicVolume ( const unsigned int  percent_)

Sets the volume for the music.

If the percent_ is over 100, will be set to 100.

Parameters
percent_: The volume percentage (0-100).

Member Data Documentation

Mix_Chunk* AudioHandler::currentEffect
private

The current effect that is playing.

Mix_Music* AudioHandler::currentMusic
private

The current music that is playing.


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