//
// FMODAudioEngine::setChannelVolumeMod from 0x1003e6340 to 0x1003e6526 (486 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::updateGameObjects @ 0x1000de801
// > GJBaseGameLayer::update @ 0x1001530f2
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x1001563f5
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x10015e908
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
void __fastcall FMODAudioEngine::setChannelVolumeMod(FMODAudioEngine *a1, int a2, AudioTargetType a3, float a4)
{
float *v4; // rax
__m128 v5; // xmm0
FMOD::ChannelGroup *ChannelGroup; // r13
__m128 v7; // xmm0
FMOD::ChannelGroup *v8; // rbx
float *v9; // rax
float v10; // xmm0_4
FMOD::ChannelControl *v11; // rdi
float *v12; // rax
__m128 v13; // xmm0
int MusicChannelID; // eax
FMOD::Channel *v15; // rax
FMOD::Channel *v16; // r15
float *p_m_volumeForMusicChannels; // rbx
float *v18; // rax
FMOD::Channel *v19; // rax
float *v20; // rax
int v21; // [rsp+0h] [rbp-40h] BYREF
float v22; // [rsp+4h] [rbp-3Ch]
__int64 v23; // [rsp+8h] [rbp-38h] BYREF
v21 = a2;
v22 = a4;
if ( a3 == MusicChannel )
{
v23 = (__int64)&v21;
v12 = (float *)sub_100174230(
(float *)&a1->m_audioState.m_volumeModForMusicChannels,
&v21,
*(__m128 *)&a4,
(__int64)&unk_10081B0A2,
(_DWORD **)&v23);
v13 = (__m128)LODWORD(v22);
v12[5] = v22;
MusicChannelID = FMODAudioEngine::getMusicChannelID(a1, v21);
v15 = FMODAudioEngine::channelForChannelID(a1, MusicChannelID);
if ( !v15 )
return;
v16 = v15;
p_m_volumeForMusicChannels = (float *)&a1->m_audioState.m_volumeForMusicChannels;
LABEL_8:
v23 = (__int64)&v21;
v20 = (float *)sub_100174230(p_m_volumeForMusicChannels, &v21, v13, (__int64)&unk_10081B0A2, (_DWORD **)&v23);
v10 = v22 * v20[5];
v11 = v16;
goto LABEL_9;
}
if ( a3 != SFXGroup )
{
v23 = (__int64)&v21;
v18 = (float *)sub_100174230(
(float *)&a1->m_audioState.m_volumeModForEffectChannels,
&v21,
*(__m128 *)&a4,
(__int64)&unk_10081B0A2,
(_DWORD **)&v23);
v13 = (__m128)LODWORD(v22);
v18[5] = v22;
v19 = FMODAudioEngine::channelForChannelID(a1, v21);
if ( !v19 )
return;
v16 = v19;
p_m_volumeForMusicChannels = (float *)&a1->m_audioState.m_volumeForEffectChannels;
goto LABEL_8;
}
v23 = (__int64)&v21;
v4 = (float *)sub_100174230(
(float *)&a1->m_audioState.m_volumeModForEffectGroups,
&v21,
*(__m128 *)&a4,
(__int64)&unk_10081B0A2,
(_DWORD **)&v23);
v5 = (__m128)LODWORD(v22);
v4[5] = v22;
v23 = 0x3FF0000000000000LL;
sub_1003EE240(&a1->m_audioState.m_volumeForEffectGroups, &v21, &v21, &v23);
ChannelGroup = FMODAudioEngine::getChannelGroup(a1, v21, 0);
v23 = (__int64)&v21;
v7 = (__m128)*((unsigned int *)sub_100174230(
(float *)&a1->m_audioState.m_volumeForEffectGroups,
&v21,
v5,
(__int64)&unk_10081B0A2,
(_DWORD **)&v23)
+ 5);
v7.f32[0] = v7.f32[0] * v22;
FMOD::ChannelControl::setVolume(ChannelGroup, v7.f32[0]);
v8 = FMODAudioEngine::getChannelGroup(a1, v21, 1);
v23 = (__int64)&v21;
v9 = (float *)sub_100174230(
(float *)&a1->m_audioState.m_volumeForEffectGroups,
&v21,
v7,
(__int64)&unk_10081B0A2,
(_DWORD **)&v23);
v10 = v22 * v9[5];
v11 = v8;
LABEL_9:
FMOD::ChannelControl::setVolume(v11, v10);
}