//
// FMODAudioEngine::fadeMusic from 0x1003e9fd0 to 0x1003ea0ae (222 bytes)
//
// 3 xrefs:
// > SecretRewardsLayer::onGoldChest @ 0x10063261a
// > SecretRewardsLayer::fadeInMusic @ 0x10063a2e7
// > SecretRewardsLayer::fadeInOutMusic @ 0x10063a357
//
// 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 __fastcall FMODAudioEngine::fadeMusic(FMODAudioEngine *a1, float a2, int a3, float a4, float a5)
{
FMOD::Channel *ActiveMusicChannel; // rax
FMOD::ChannelControl *v6; // r14
float v7; // xmm0_4
unsigned __int64 v8; // [rsp+8h] [rbp-28h] BYREF
float v9; // [rsp+14h] [rbp-1Ch]
float v10; // [rsp+18h] [rbp-18h]
float v11; // [rsp+1Ch] [rbp-14h]
v9 = a5;
v11 = a4;
v10 = a2;
ActiveMusicChannel = FMODAudioEngine::getActiveMusicChannel(a1, a3);
if ( ActiveMusicChannel )
{
v6 = ActiveMusicChannel;
FMODAudioEngine::stopAndGetFade(a1, ActiveMusicChannel);
a1->m_lastResult = FMOD::ChannelControl::getDSPClock(v6, nullptr, &v8);
a1->m_lastResult = FMOD::ChannelControl::addFadePoint(v6, v8, v11);
if ( (v8 & 0x8000000000000000LL) != 0LL )
v7 = (float)(int)((v8 >> 1) | v8 & 1) + (float)(int)((v8 >> 1) | v8 & 1);
else
v7 = (float)(int)v8;
a1->m_lastResult = FMOD::ChannelControl::addFadePoint(
v6,
(unsigned int)(int)(float)((float)((float)a1->m_sampleRate * v10) + v7),
v9);
}
}