mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(sound): add SESound::SetChannelGroup
This commit is contained in:
parent
d5cebf9a02
commit
873342dba8
@ -679,6 +679,26 @@ void SESound::Play() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SESound::SetChannelGroup(const char* name, bool inMaster) {
|
||||||
|
if (!this->m_internal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SESound::s_Initialized || !name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto channelGroup = SESound::GetChannelGroup(name, true, inMaster);
|
||||||
|
|
||||||
|
// Get index in array (probably a member function on TSBaseArray)
|
||||||
|
auto channelGroupOffset = reinterpret_cast<intptr_t>(channelGroup) - reinterpret_cast<intptr_t>(SESound::s_ChannelGroups.m_data);
|
||||||
|
auto channelGroupIndex = static_cast<int32_t>(channelGroupOffset / sizeof(SEChannelGroup));
|
||||||
|
|
||||||
|
this->m_internal->m_channelGroup = channelGroupIndex;
|
||||||
|
|
||||||
|
this->m_internal->UpdateVolume();
|
||||||
|
}
|
||||||
|
|
||||||
void SESound::SetFadeInTime(float fadeInTime) {
|
void SESound::SetFadeInTime(float fadeInTime) {
|
||||||
if (!this->m_internal) {
|
if (!this->m_internal) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class SESound {
|
|||||||
bool IsPlaying();
|
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);
|
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();
|
void Play();
|
||||||
|
void SetChannelGroup(const char* name, bool inMaster);
|
||||||
void SetFadeInTime(float fadeInTime);
|
void SetFadeInTime(float fadeInTime);
|
||||||
void SetFadeOutTime(float fadeOutTime);
|
void SetFadeOutTime(float fadeOutTime);
|
||||||
void SetUserData(SEUserData* userData);
|
void SetUserData(SEUserData* userData);
|
||||||
|
|||||||
@ -43,6 +43,14 @@ void SESoundInternal::Play() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SESoundInternal::UpdateVolume() {
|
||||||
|
if (!this->m_fmodChannel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_fmodChannel->setVolume(this->GetVolume());
|
||||||
|
}
|
||||||
|
|
||||||
SEDiskSound::SEDiskSound() : SESoundInternal() {
|
SEDiskSound::SEDiskSound() : SESoundInternal() {
|
||||||
SESound::s_InternalCritSect.Enter();
|
SESound::s_InternalCritSect.Enter();
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class SESoundInternal : public TSLinkedNode<SESoundInternal> {
|
|||||||
int32_t m_useCache = 0;
|
int32_t m_useCache = 0;
|
||||||
int32_t m_type = 0;
|
int32_t m_type = 0;
|
||||||
// TODO
|
// TODO
|
||||||
|
int32_t m_channelGroup = 0;
|
||||||
FMOD_MODE m_fmodMode = FMOD_DEFAULT;
|
FMOD_MODE m_fmodMode = FMOD_DEFAULT;
|
||||||
uint8_t m_playing = 0;
|
uint8_t m_playing = 0;
|
||||||
uint8_t m_stopped = 0;
|
uint8_t m_stopped = 0;
|
||||||
@ -53,6 +54,7 @@ class SESoundInternal : public TSLinkedNode<SESoundInternal> {
|
|||||||
SESoundInternal();
|
SESoundInternal();
|
||||||
float GetVolume();
|
float GetVolume();
|
||||||
void Play();
|
void Play();
|
||||||
|
void UpdateVolume();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SEDiskSound : public SESoundInternal {
|
class SEDiskSound : public SESoundInternal {
|
||||||
|
|||||||
@ -414,7 +414,11 @@ int32_t SI2::PlaySoundKit(int32_t id, int32_t a2, SOUNDKITOBJECT* object, SoundK
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// Set channel group based on sound type
|
||||||
|
|
||||||
|
sound->SetChannelGroup(SI2::s_ChannelGroupNames[properties->m_type], properties->m_type != 3);
|
||||||
|
|
||||||
|
// Set user data
|
||||||
|
|
||||||
auto userData = STORM_NEW(SI2USERDATA);
|
auto userData = STORM_NEW(SI2USERDATA);
|
||||||
userData->m_name = soundKitDef->name ? soundKitDef->name : "<UNKNOWN ERROR>";
|
userData->m_name = soundKitDef->name ? soundKitDef->name : "<UNKNOWN ERROR>";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user