I can't play it module it just crashes with no error message

    result = FMOD::System_Create(&system);
result = system->getVersion(&version);

if (version < FMOD_VERSION)
{
	std::cout << "FMOD lib version %08x doesn't match header version %08x" << std::endl;
}

result = system->createStream("bgm_boss.it", FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);

do {
	result = system->playSound(sound, 0, false, &channel);
	result = system->update();

} while (apprunning);
return 0;

}

I canā€™t see where you create your ā€œsoundā€ variable, make sure you include everything.

Iā€™ve never used those options for ā€œcreateStreamā€, just FMOD_CREATESTREAM.

Eg. this works for me;

FMOD_RESULT result;
FMOD::System *system = NULL;
result = FMOD::System_Create(&system);      // Create the main system object.
result = system->init(512, FMOD_INIT_NORMAL, 0);    // Initialize FMOD.
FMOD::Sound *bg_music;
system->createSound("assets/castlevania_4_cv-1.xm", FMOD_CREATESTREAM, NULL, &bg_music);
FMOD::Channel *channel;
system->playSound(bg_music, NULL, false, &channel);
while(1);

The important thing is - have you tried it with other module files? Try a different .IT file, or a .MOD file, does it still crash? If it crashes with every file you try, then something is wrong with your code. If it only crashes with that one file, then perhaps itā€™s a problem with that file, and you can maybe load it into OpenMPT or MilkyTracker and re-save it, see if that fixes it, something like that.

Iā€™m guessing by ā€˜crashā€™ you mean hang? Because your inner loop is spamming calls to playSound, which means it will try and start the sound from the start a million times a second.

I would move your playSound outside of the loop, and replace it with a call to Sleep(10); to stop it hogging the CPU.

1 Like

What Brett stated is exactly what I saw in the example codeā€¦an endless loop spamming the play call; it will be very fast, and many thousands of calls with no time in between to actually perform anything properly. I would think that canā€™t be a good thing and could very well cause problems.