Tutoral: use sound-set

Objectifs:

  • Understand config file
  • Create a simple playing sounds

Create a configuration file

configuration file is really simple:

soundSet.json

it contain 2 mains object:

  • musics: That containig the list of all music files
  • effects: That contain all effects files

A simple example:

{
musics:{
"BG-1":"DATA:audio/Clean Soul.ogg"
"BG-22":"DATA:audio/Dark knight.ogg"
},
effects:{
"end":"DATA:audio/end.wav",
"error":"DATA:audio/error.wav",
"levelup":"DATA:audio/levelup.wav",
"ok":"DATA:audio/ok.wav"
}
}

what you need to do first:

Include and basic init:

#include <audio/ess/ess.hpp>
//in the main application:
int main(...) {
audio::ess::init();
/*
* Do your stuff
*/
audio::ess::unInit();
return 0;
}

Select your sound set file:

audio::ess::soundSetLoad("DATA:soundSet.json");

Play a background music:

Start playing:

audio::ess::musicPlay("BG-22");

Stop playing:

audio::ess::musicStop();

Change volume: (reduce at -5dB)

audio::ess::musicSetVolume(-5.0f);

Play an effect:

Start playing:

audio::ess::effectPlay("error");
sleep(1);
audio::ess::effectPlay("levelup");

or (faster way):

int32_t effectId = audio::ess::effectGetId("error");
audio::ess::effectPlay(effectId);

Note: An effect can not stopped ...

Change volume: (reduce at -5dB)

audio::ess::effectSetVolume(-5.0f);