//
// FMODAudioEngine::fadeInMusic from 0x14005c3f0 to 0x14005c524 (308 bytes)
//
// 7 xrefs:
// > FMODAudioEngine::playMusic @ 0x14005a1d0
// > GauntletSelectLayer::unlockAnimationStep3 @ 0x1401fc05e
// > GJPathPage::unlockAnimationStep3 @ 0x140288d98
// > PlayLayer::startMusic @ 0x1403bab44
// > ??> @ 0x140664f28
// > ??> @ 0x140664f38
// > ??> @ 0x1406c5400
//
// 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::fadeInMusic(FMODAudioEngine *a1, float a2, int a3)
{
__int64 v4; // rax
FMOD::Channel *v5; // rax
FMOD::ChannelControl *v6; // rdi
enum FMOD_RESULT DSPClock; // eax
unsigned __int64 v8; // rdx
enum FMOD_RESULT v9; // eax
__m128i v10; // xmm0
__int64 v11; // rcx
float v12; // xmm0_4
float v13; // xmm1_4
float v14; // xmm0_4
unsigned __int64 v15; // rax
_BYTE v16[16]; // [rsp+20h] [rbp-28h] BYREF
unsigned __int64 v17; // [rsp+50h] [rbp+8h] BYREF
int v18; // [rsp+60h] [rbp+18h] BYREF
v18 = 0;
if ( sub_14005F8D0(&a1->m_fmodMusic, &v18) )
{
v4 = sub_140061560(&a1->m_fmodMusic, v16, &v18);
v5 = FMODAudioEngine::channelForChannelID(a1, *(_DWORD *)(*(_QWORD *)v4 + 24LL));
v6 = v5;
if ( v5 )
{
FMODAudioEngine::stopAndGetFade(a1, v5);
DSPClock = FMOD::ChannelControl::getDSPClock(v6, nullptr, &v17);
v8 = v17;
a1->m_lastResult = DSPClock;
v9 = FMOD::ChannelControl::addFadePoint(v6, v8, 0.0);
v10 = _mm_cvtsi32_si128(a1->m_sampleRate);
v11 = v17;
a1->m_lastResult = v9;
v12 = _mm_cvtepi32_ps(v10).m128_f32[0] * a2;
if ( v11 < 0 )
v13 = (float)(v11 & 1 | (unsigned int)((unsigned __int64)v11 >> 1))
+ (float)(v11 & 1 | (unsigned int)((unsigned __int64)v11 >> 1));
else
v13 = (float)(int)v11;
v14 = v12 + v13;
v15 = 0;
if ( v14 >= 9.223372e18 )
{
v14 = v14 - 9.223372e18;
if ( v14 < 9.223372e18 )
v15 = 0x8000000000000000uLL;
}
a1->m_lastResult = FMOD::ChannelControl::addFadePoint(v6, v15 + (unsigned int)(int)v14, 1.0);
}
}
}