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);
result = system->playSound(sound, 0, false, &channel);
result = system->update();
} while (apprunning);
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::System *system = NULL;
result = FMOD::System_Create(&system); // Create the main system object.
result = system->init(512, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
system->createSound("assets/castlevania_4_cv-1.xm", FMOD_CREATESTREAM, NULL, &bg_music);
system->playSound(bg_music, NULL, false, &channel);
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.
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.