I know this is very basic question and really sorry to ask here,
but I’m not that familiar with Windows specific programming.
I used to write code which can run on multiple platforms like Windows, Linux, and Android at the same time using FMOD Ex and FMOD Studio.
I haven’t encountered any issue, but today I found this statement from this link (https://fmod.com/resources/documentation-api?version=2.0&page=platforms-windows.html):
“Before calling any FMOD functions it is important to ensure COM is initialized.”
I’ve heard about COM objects very long time ago when I learned DirectX programming at school but forgot everything.
I’m in a hurry, so don’t have time to understand COM fully, and just need to get FMOD Studio working properly on Windows now.
So could you help me out, please?
-
What does COM have to do with FMOD and why do we need the additional initialization process that we don’t on other platforms?
-
Could you show me the simplest code example with CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED) and CoUninitialize() which can be added to my current working project?
Say, I have code below:
void init() {
FMOD_System_Create(&g_System);
FMOD_System_Init(g_System, 1024, FMOD_INIT_NORMAL, NULL);
FMOD_System_CreateSound(g_System, g_szFile, FMOD_DEFAULT, NULL, &g_Sound);
FMOD_System_CreateDSPByType(g_System, FMOD_DSP_TYPE_PITCHSHIFT, &g_DSP_pitch);
FMOD_System_CreateDSPByType(g_System, FMOD_DSP_TYPE_ECHO, &g_DSP_echo);
FMOD_DSP_SetParameterFloat(g_DSP_pitch, FMOD_DSP_PITCHSHIFT_PITCH, 1.f);
}
void release() {
FMOD_Sound_Release(g_Sound);
FMOD_Channel_RemoveDSP(channel, g_DSP_pitch);
FMOD_Channel_RemoveDSP(channel, g_DSP_echo);
FMOD_DSP_Release(g_DSP_pitch);
FMOD_DSP_Release(g_DSP_echo);
FMOD_System_Release(g_System);
}