Ok, in my game I have so you can select a mid or wav file to play as music. For some reason if I open a mid, another mid and a wav it crashes. I'm using the Windows API and fmod to play my music.
Is there anything wrong with my method of accomplishing things?
In my program I have an integer to track whether the current file is a mid or wav and then in my Windows procdure I use the approiate functions to the play the right type music.
Code:
#define MUSIC_MID 0
#define MUSIC_WAV 1
int music_type = 0;
if(GetOpenFileName(&ofn))
{
FSOUND_Sample_Free(wav_music);
FMUSIC_FreeSong(music);
if(strstr(szFileName,".wav"))
{
musicType = MUSIC_WAV;
wav_music = FSOUND_Sample_Load(2,szFileName,FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_PlaySound(2,wav_music);
}
else if(strstr(szFileName,".mid"))
{
musicType = MUSIC_MID;
music = FMUSIC_LoadSong(szFileName);
FMUSIC_SetLooping(music,TRUE);
FMUSIC_PlaySong(music);
}
}