Sound Manager

Learn how to play sounds and music

The Sound Manager

The Sound Manager is a component of your Scene Class that allows you to play any sounds and music loaded by the Engine. It can also be used to adjust the volumes of your sounds and music. You access the Sound Manager by calling the the nero::Scene method getSoundManager().

getSoundManager()->playMusic("music_name");

Play Music

The Sound Manager offers several methods to interact with music. Each music is identified by its name (the name of music file inside the folder resource/music). The Engine plays one music at a time. When you call the method playMusic(name), the engine select and start playing the music. Once a music is being played you can pause it, resume it and stop it. By default Music are played in loop.

void	playMusic(std::string name); //Select and play a music
void  	pauseMusic(); //pause the selected music
void   	resumeMusic(); //remuse the selected music after a pause
void 	stopMusic(); //stop playing the selected music

Play Sounds

Sound are relative short (a few seconds), so the Sound Manager only offers one method to play them. Once a sound finish to play, it stop automatically. The Engine can play ten (10) sounds at the same time, If you already have 10 sounds playing and you want to play another one, the Engine will stop the first of ten sound and play the new one. This mechanism is called Object pool pattern.

void playSound(std::string name);

Retrieve and Adjust Volume

whether a music or a sound is being played, you can retrieve or adjust the volumes with the methods below.

//get music volume
float               getMusicVolume();
//adjust music volume
void                setMusicVolume(float volume);
float               increaseMusicVolume(float offset = 1.f);
float               decreaseMusicVolume(float offset = 1.f);
//get sound volume
float               getSoundVolume();
//adjust sound volume
void                setSoundVolume(float volume);
float               increaseSoundVolume(float offset = 1.f);
float               decreaseSoundVolume(float offset = 1.f);