diff --git a/src/sound/SESound.cpp b/src/sound/SESound.cpp index 9021dc4..09e1ced 100644 --- a/src/sound/SESound.cpp +++ b/src/sound/SESound.cpp @@ -18,6 +18,23 @@ void FSoundFreeCallback(void* ptr, FMOD_MEMORY_TYPE type, const char *sourcestr) SMemFree(ptr, "FMod", 0, 0x0); } +FMOD::SoundGroup* SESound::CreateSoundGroup(const char* name, int32_t maxAudible) { + FMOD::SoundGroup* group = nullptr; + FMOD_RESULT result; + + result = SESound::s_pGameSystem->createSoundGroup(name, &group); + if (result != FMOD_OK && result != FMOD_ERR_CHANNEL_STOLEN && result != FMOD_ERR_INVALID_HANDLE && result != FMOD_ERR_OUTPUT_DRIVERCALL) { + LOG_WRITE(result, ""); + } + + result = group->setMaxAudible(maxAudible); + if (result != FMOD_OK && result != FMOD_ERR_CHANNEL_STOLEN && result != FMOD_ERR_INVALID_HANDLE && result != FMOD_ERR_OUTPUT_DRIVERCALL) { + LOG_WRITE(result, ""); + } + + return group; +} + void SESound::Init(int32_t maxChannels, int32_t* a2, int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void* a8, int32_t a9) { // TODO diff --git a/src/sound/SESound.hpp b/src/sound/SESound.hpp index 75eed8f..166db22 100644 --- a/src/sound/SESound.hpp +++ b/src/sound/SESound.hpp @@ -10,6 +10,7 @@ class SESound { static FMOD::System* s_pGameSystem; // Static functions + static FMOD::SoundGroup* CreateSoundGroup(const char* name, int32_t maxAudible); static void Init(int32_t maxChannels, int32_t (*a2), int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void (*a8), int32_t a9); static void Log_Write(int32_t line, const char* file, FMOD_RESULT result, const char* fmt, ...); }; diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index e710e36..b3bd4ce 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -97,8 +97,11 @@ int32_t SI2::Init(int32_t a1) { if (!a1) { SI2::InitSoundKitDefs(); + // TODO } + SI2::InitSoundKitGroups(); + // TODO return 0; @@ -176,6 +179,17 @@ void SI2::InitSoundKitDefs() { } } +void SI2::InitSoundKitGroups() { + for (uint32_t i = 0; i < SI2::s_SoundKitDefs.Count(); i++) { + auto soundKitDef = SI2::s_SoundKitDefs[i]; + + if (soundKitDef && soundKitDef->name) { + soundKitDef->soundGroup1 = SESound::CreateSoundGroup(soundKitDef->name, 3); + soundKitDef->soundGroup2 = SESound::CreateSoundGroup(soundKitDef->name, 3); + } + } +} + void SI2::RegisterCVars() { CVar::Register( "StartTalkingDelay", diff --git a/src/sound/SI2.hpp b/src/sound/SI2.hpp index b315979..3eb6ae9 100644 --- a/src/sound/SI2.hpp +++ b/src/sound/SI2.hpp @@ -1,15 +1,15 @@ #ifndef SOUND_SI2_HPP #define SOUND_SI2_HPP -#include "SOUNDKITLOOKUP.hpp" #include "sound/SI2Script.hpp" #include "storm/hash/Hashkey.hpp" #include "storm/hash/TSHashTable.hpp" #include "ui/Types.hpp" -#include #include +#include class SOUNDKITDEF; +struct SOUNDKITLOOKUP; class SI2 { public: @@ -21,6 +21,7 @@ class SI2 { // Static functions static int32_t Init(int32_t a1); static void InitSoundKitDefs(); + static void InitSoundKitGroups(); static void RegisterCVars(); static void RegisterScriptFunctions(); }; diff --git a/src/sound/SOUNDKITDEF.hpp b/src/sound/SOUNDKITDEF.hpp index 15d57ca..dc3f82b 100644 --- a/src/sound/SOUNDKITDEF.hpp +++ b/src/sound/SOUNDKITDEF.hpp @@ -2,9 +2,12 @@ #define SOUND_SOUND_KIT_DEF_HPP #include "db/Db.hpp" -#include #include +namespace FMOD { + class SoundGroup; +} + class SOUNDKITDEF { public: const char* name;