//
// FMODAudioEngine::setupAudioEngine from 0x3e7cc8 to 0x3e7f16 (590 bytes)
//
// 1 xrefs:
// > FMODAudioEngine::setup @ 0x3ec40a
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:47:05 +0000
//
int __fastcall FMODAudioEngine::setupAudioEngine(FMODAudioEngine *this)
{
FMOD::System *v2; // r0
FMOD::System *v3; // r0
GameManager *StreamBufferSize; // r0
GameManager *v5; // r0
GameManager *SoftwareFormat; // r0
GameManager *v7; // r0
int GameVariable; // r0
int v9; // r1
unsigned int v11; // [sp+0h] [bp-30h] BYREF
unsigned int v12; // [sp+4h] [bp-2Ch] BYREF
unsigned int v13; // [sp+8h] [bp-28h] BYREF
unsigned int v14; // [sp+Ch] [bp-24h] BYREF
int v15[3]; // [sp+10h] [bp-20h] BYREF
FMOD::DSP *v16; // [sp+24h] [bp-Ch]
FMOD::DSP *v17; // [sp+28h] [bp-8h]
*((_DWORD *)this + 97) = FMOD_System_Create();
ERRCHECK_fn();
v2 = *((FMOD::System **)this + 91);
v11 = 0;
FMOD::System::getVersion(v2, &v11);
FMOD_Debug_Initialize();
v3 = *((FMOD::System **)this + 91);
v12 = 0;
v13 = 1;
StreamBufferSize = (GameManager *)FMOD::System::getStreamBufferSize(v3, &v12, &v13);
v5 = (GameManager *)GameManager::sharedState(StreamBufferSize);
if ( !GameManager::getGameVariable(v5, "0159") )
FMOD::System::setDSPBufferSize(*((FMOD::System **)this + 91), 0x200u, 4);
FMOD::System::getDSPBufferSize(*((FMOD::System **)this + 91), &v14, v15);
FMOD::System::getSoftwareFormat();
SoftwareFormat = (GameManager *)FMOD::System::getSoftwareFormat();
v7 = (GameManager *)GameManager::sharedState(SoftwareFormat);
GameVariable = GameManager::getGameVariable(v7, "0142");
v9 = 44100;
*((_BYTE *)this + 396) = GameVariable;
if ( GameVariable )
v9 = 24000;
v15[2] = v9;
FMOD::System::setSoftwareFormat();
*((_DWORD *)this + 97) = FMOD::System::init(*((FMOD::System **)this + 91), 128, 0, nullptr);
ERRCHECK_fn();
*((_DWORD *)this + 97) = FMOD::System::getSoftwareFormat();
ERRCHECK_fn();
FMOD::System::createChannelGroup(*((FMOD::System **)this + 91), nullptr, (FMOD::ChannelGroup **)this + 90);
FMOD::ChannelControl::setVolumeRamp(*((FMOD::ChannelControl **)this + 90), 0);
FMOD::ChannelControl::getDSP(*((FMOD::ChannelControl **)this + 90), -1, (FMOD::DSP **)this + 92);
FMOD::DSP::setMeteringEnabled(*((FMOD::DSP **)this + 92), 0, 1);
FMOD::System::createChannelGroup(*((FMOD::System **)this + 91), nullptr, (FMOD::ChannelGroup **)this + 94);
FMOD::System::createChannelGroup(*((FMOD::System **)this + 91), nullptr, (FMOD::ChannelGroup **)this + 95);
FMOD::ChannelGroup::addGroup();
FMOD::System::createChannelGroup(*((FMOD::System **)this + 91), nullptr, (FMOD::ChannelGroup **)this + 96);
v16 = nullptr;
FMOD::System::createDSPByType();
FMOD::DSP::setParameterFloat(v16, 1, 0.0);
FMOD::DSP::setParameterBool(v16, 3, 1);
*((_DWORD *)this + 97) = FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 94), 1, v16);
ERRCHECK_fn();
FMOD::System::createDSPByType();
FMOD::DSP::setParameterFloat(v16, 1, 0.0);
FMOD::DSP::setParameterBool(v16, 3, 1);
*((_DWORD *)this + 97) = FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 90), 1, v16);
ERRCHECK_fn();
v17 = nullptr;
FMOD::System::createDSPByType();
FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 95), 0, v17);
FMODAudioEngine::updateReverb((int)this, *((_DWORD *)this + 202), 1);
FMOD::ChannelControl::getDSP(*((FMOD::ChannelControl **)this + 94), -1, (FMOD::DSP **)this + 93);
return FMOD::DSP::setMeteringEnabled(*((FMOD::DSP **)this + 93), 0, 1);
}