0
0
    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;

}

  • You must to post comments
1
0

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.

  • You must to post comments
0
0

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.

  • You must to post comments
0
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.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.