From 4669e306c351fd2d374c45250aeb9e093171e3ac Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 26 Nov 2025 18:59:06 -0600 Subject: [PATCH] feat(sound): add SI2::IsPlaying --- src/sound/SESound.cpp | 15 +++++++++++++++ src/sound/SESound.hpp | 1 + src/sound/SI2.cpp | 5 +++++ src/sound/SI2.hpp | 2 ++ src/sound/SOUNDKITOBJECT.hpp | 14 ++++++++++++++ 5 files changed, 37 insertions(+) create mode 100644 src/sound/SOUNDKITOBJECT.hpp diff --git a/src/sound/SESound.cpp b/src/sound/SESound.cpp index faabde2..cfe46e8 100644 --- a/src/sound/SESound.cpp +++ b/src/sound/SESound.cpp @@ -538,6 +538,21 @@ void SESound::CompleteLoad() { } } +bool SESound::IsPlaying() { + if (!this->m_internal) { + return 0; + } + + if (!this->m_internal->m_fmodChannel) { + return 0; + } + + bool isPlaying; + this->m_internal->m_fmodChannel->isPlaying(&isPlaying); + + return isPlaying; +} + int32_t SESound::Load(const char* filename, int32_t a3, FMOD::SoundGroup* soundGroup1, FMOD::SoundGroup* soundGroup2, bool a6, bool a7, uint32_t a8, int32_t a9, uint32_t a10) { if (!SESound::s_Initialized) { return 0; diff --git a/src/sound/SESound.hpp b/src/sound/SESound.hpp index b2b5f57..47580f9 100644 --- a/src/sound/SESound.hpp +++ b/src/sound/SESound.hpp @@ -35,6 +35,7 @@ class SESound { // Public member functions void CompleteLoad(); + bool IsPlaying(); int32_t Load(const char* filename, int32_t a3, FMOD::SoundGroup* soundGroup1, FMOD::SoundGroup* soundGroup2, bool a6, bool a7, uint32_t a8, int32_t a9, uint32_t a10); void Play(); diff --git a/src/sound/SI2.cpp b/src/sound/SI2.cpp index 7f84bc2..5663e38 100644 --- a/src/sound/SI2.cpp +++ b/src/sound/SI2.cpp @@ -5,6 +5,7 @@ #include "sound/SESound.hpp" #include "sound/SOUNDKITDEF.hpp" #include "sound/SOUNDKITLOOKUP.hpp" +#include "sound/SOUNDKITOBJECT.hpp" #include "ui/FrameScript.hpp" TSGrowableArray SI2::s_SoundKitDefs; @@ -230,6 +231,10 @@ void SI2::InitSoundKitGroups() { } } +bool SI2::IsPlaying(SOUNDKITOBJECT* object) { + return object->m_sound->IsPlaying(); +} + int32_t SI2::PlaySoundKit(int32_t id, int32_t a2, void* handle, SoundKitProperties* properties, int32_t a5, void* a6, int32_t a7, int32_t a8) { // Basic validations diff --git a/src/sound/SI2.hpp b/src/sound/SI2.hpp index f6af22a..9af5882 100644 --- a/src/sound/SI2.hpp +++ b/src/sound/SI2.hpp @@ -9,6 +9,7 @@ class SOUNDKITDEF; struct SOUNDKITLOOKUP; +class SOUNDKITOBJECT; class SoundKitProperties; class SI2 { @@ -25,6 +26,7 @@ class SI2 { static int32_t Init(int32_t a1); static void InitSoundKitDefs(); static void InitSoundKitGroups(); + static bool IsPlaying(SOUNDKITOBJECT* object); static int32_t PlaySoundKit(int32_t id, int32_t a2, void* handle, SoundKitProperties* properties, int32_t a5, void* a6, int32_t a7, int32_t a8); static void PlayUISound(int32_t id); static void RegisterCVars(); diff --git a/src/sound/SOUNDKITOBJECT.hpp b/src/sound/SOUNDKITOBJECT.hpp new file mode 100644 index 0000000..b7246cc --- /dev/null +++ b/src/sound/SOUNDKITOBJECT.hpp @@ -0,0 +1,14 @@ +#ifndef SOUND_SOUND_KIT_OBJECT_HPP +#define SOUND_SOUND_KIT_OBJECT_HPP + +class SESound; + +class SOUNDKITOBJECT { + public: + // Member variables + // TODO + SESound* m_sound; + // TODO +}; + +#endif