Added Sound effect configuration and implementation.

This commit is contained in:
2024-01-08 05:26:20 -06:00
parent 6539bbdb50
commit 0643393b9c
13 changed files with 259 additions and 57 deletions
+5 -10
View File
@@ -48,7 +48,9 @@ void Audio::Initialize(){
Engine().SetBackgroundPlay(true);
Self().events.insert("Default Volume");
for(auto&[key,data]:DATA["Events"]){
Self().events.insert(key);
if(key!="SFX"){ //HACK ALERT! We are specifically excluding the SFX key because it's used to specify the sound effects in-game.
Self().events.insert(key);
}
}
for(auto&[songFileName,size]:DATA["BGM"]){
auto&data=DATA["BGM"][songFileName];
@@ -67,14 +69,7 @@ void Audio::Initialize(){
channelCounter++;
}
if(!data.HasProperty("Default Volume"))ERR(std::format("WARNING! Track {} does not have a Default Volume parameter!",bgm.GetName()));
if(data["Default Volume"].GetValueCount()!=bgm.GetChannelCount())ERR(std::format("WARNING! Default Volume parameters do not match channel count. {} != {}",data["Default Volume"].GetValueCount(),bgm.GetChannelCount()));
VolumeList volumes;
for(int i=0;i<data["Default Volume"].GetValueCount();i++){
volumes.push_back(data["Default Volume"].GetInt(i)/100.f);
}
bgm.AddEventVolumes("Default Volume",volumes);
if(!data["Events"].HasProperty("Default Volume"))ERR(std::format("WARNING! Track {} does not have a Default Volume parameter!",bgm.GetName()));
if(data.HasProperty("Fade Time")){
bgm.SetFadeTime(data["Fade Time"].GetReal());
@@ -84,7 +79,7 @@ void Audio::Initialize(){
if(data.HasProperty("Events")){
for(auto&[eventName,size]:DATA["Events"]){
for(auto&eventName:Self().events){
auto&eventData=data["Events"][eventName];
if(eventData.GetValueCount()!=bgm.GetChannelCount())ERR(std::format("WARNING! {} parameters do not match channel count. {} != {}",eventName,eventData.GetValueCount(),bgm.GetChannelCount()));
VolumeList volumes;