//
// FMODAudioEngine::fadeOutMusic from 0x14005c530 to 0x14005c66c (316 bytes)
//
// 7 xrefs:
// > GauntletSelectLayer::playUnlockAnimation @ 0x1401fb1eb
// > GJPathPage::playUnlockAnimation @ 0x140287ddc
// > LevelAreaInnerLayer::onDoor @ 0x1402c8342
// > PlayLayer::showCompleteEffect @ 0x1403a9506
// > ??> @ 0x140664f58
// > ??> @ 0x140664f8c
// > ??> @ 0x1406c5424
//
// 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
//
void FMODAudioEngine::fadeOutMusic(FMODAudioEngine *a1, float a2, int a3)
{
__int64 v4; // rax
FMOD::Channel *v5; // rax
FMOD::ChannelControl *v6; // rdi
float Fade; // xmm6_4
enum FMOD_RESULT DSPClock; // eax
unsigned __int64 v9; // rdx
enum FMOD_RESULT v10; // eax
__m128i v11; // xmm0
__int64 v12; // rcx
float v13; // xmm0_4
float v14; // xmm1_4
float v15; // xmm0_4
unsigned __int64 v16; // rax
_BYTE v17[16]; // [rsp+20h] [rbp-38h] BYREF
unsigned __int64 v18; // [rsp+60h] [rbp+8h] BYREF
int v19; // [rsp+70h] [rbp+18h] BYREF
v19 = 0;
if ( sub_14005F8D0(&a1->m_fmodMusic, &v19) )
{
v4 = sub_140061560(&a1->m_fmodMusic, v17, &v19);
v5 = FMODAudioEngine::channelForChannelID(a1, *(_DWORD *)(*(_QWORD *)v4 + 24LL));
v6 = v5;
if ( v5 )
{
Fade = FMODAudioEngine::stopAndGetFade(a1, v5);
DSPClock = FMOD::ChannelControl::getDSPClock(v6, nullptr, &v18);
v9 = v18;
a1->m_lastResult = DSPClock;
v10 = FMOD::ChannelControl::addFadePoint(v6, v9, Fade);
v11 = _mm_cvtsi32_si128(a1->m_sampleRate);
v12 = v18;
a1->m_lastResult = v10;
v13 = _mm_cvtepi32_ps(v11).m128_f32[0] * a2;
if ( v12 < 0 )
v14 = (float)(v12 & 1 | (unsigned int)((unsigned __int64)v12 >> 1))
+ (float)(v12 & 1 | (unsigned int)((unsigned __int64)v12 >> 1));
else
v14 = (float)(int)v12;
v15 = v13 + v14;
v16 = 0;
if ( v15 >= 9.223372e18 )
{
v15 = v15 - 9.223372e18;
if ( v15 < 9.223372e18 )
v16 = 0x8000000000000000uLL;
}
a1->m_lastResult = FMOD::ChannelControl::addFadePoint(v6, v16 + (unsigned int)(int)v15, 0.0);
}
}
}