//
// FMODAudioEngine::playMusic from 0x1003e6f00 to 0x1003e709e (414 bytes)
//
// 6 xrefs:
// > PlayLayer::togglePracticeMode @ 0x1000be1ef
// > GJShopLayer::init @ 0x100323b4e
// > GJShopLayer::showReactMessage @ 0x1003264e3
// > GameManager::playMenuMusic @ 0x100377126
// > GameManager::fadeInMusic @ 0x1003774a1
// > CustomSongWidget::onPlayback @ 0x10061c0e8
//
// 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::playMusic(__int64 a1, __int128 *a2, unsigned __int8 a3, unsigned int a4, double a5)
{
unsigned __int8 v6; // r15
FMOD::Channel *ActiveMusicChannel; // rax
FMOD::ChannelControl *v8; // r15
float v9; // xmm0_4
FMOD::Channel *v10; // rax
__int128 v11; // [rsp+0h] [rbp-40h] BYREF
void *__p; // [rsp+10h] [rbp-30h]
bool v13[8]; // [rsp+18h] [rbp-28h] BYREF
float v14; // [rsp+24h] [rbp-1Ch]
v14 = *(float *)&a5;
if ( *(_QWORD *)(a1 + 480) )
{
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v6 = a3;
sub_100006B70(&v11, *((const void **)a2 + 2), *((_QWORD *)a2 + 1), a5);
a3 = v6;
}
else
{
__p = *((void **)a2 + 2);
v11 = *a2;
}
FMODAudioEngine::loadMusic(a1, (unsigned __int8 *)&v11, a3, a4, 0, 0, (__m128)0x3F800000u, 0.0, 1.0);
if ( (v11 & 1) != 0 )
operator delete(__p);
if ( v14 > 0.0 )
{
ActiveMusicChannel = FMODAudioEngine::getActiveMusicChannel((FMODAudioEngine *)a1, a4);
if ( ActiveMusicChannel )
{
v8 = ActiveMusicChannel;
FMODAudioEngine::stopAndGetFade((FMODAudioEngine *)a1, ActiveMusicChannel);
*(_DWORD *)(a1 + 528) = FMOD::ChannelControl::getDSPClock(v8, nullptr, (unsigned __int64 *)v13);
*(_DWORD *)(a1 + 528) = FMOD::ChannelControl::addFadePoint(v8, *(unsigned __int64 *)v13, 0.0);
if ( *(__int64 *)v13 < 0 )
v9 = (float)(int)((*(_QWORD *)v13 >> 1) | v13[0]) + (float)(int)((*(_QWORD *)v13 >> 1) | v13[0]);
else
v9 = (float)*(int *)v13;
*(_DWORD *)(a1 + 528) = FMOD::ChannelControl::addFadePoint(
v8,
(unsigned int)(int)(float)((float)((float)*(int *)(a1 + 532) * v14) + v9),
1.0);
}
}
v10 = FMODAudioEngine::getActiveMusicChannel((FMODAudioEngine *)a1, a4);
if ( v10 )
FMOD::ChannelControl::setPaused(v10, 0);
v13[0] = 0;
FMOD::ChannelControl::getPaused(*(FMOD::ChannelControl **)(a1 + 480), v13);
FMODAudioEngine::getActiveMusicChannel((FMODAudioEngine *)a1, a4);
}
}