So I have an archive that is loading the my .wav files into memory and I am trying to play a .WAV from a void* or handle in memory.
II cannot have all the .wav files in the directory and I have a function that is loading them into memory.
Here is some code that I am trying and I have tried many things , but a lot of it doesn't seem to work and I think that SDL libraries are looking for a physical file to load , but I cannot confirm that.
void *MusicTrack;
void Load_andPlay_music(ntrack){
OpenFileFromMPQ( MusicTracks[ntrack], &MusicTrack) // Opens Audio track from MPQ.
Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);
music = Mix_LoadMUS(MusicTracks[ntrack]);
// I thought that once the file is loaded it might be available as part of $PATH. This is not the case.
Mix_PlayMusic(music, -1);
}
> If I try this , ....
Mix_PlayMusic(MusicTrack, -1);
I am met with error 'int Mix_PlayMusic(Mix_Music *,int)': cannot convert argument 1 from 'void *' to 'Mix_Music *'
If you have a better solution using SDL2 then I am willing to look at that too.
Thanks.
I figured this out and it works fine
you can simply do something like this. You of course might have to change the Mix_openAudio params to meet your needs.
EDIT I ran into Other problems with this and channels overlapping. So try this out if you need SFX and Music running at the same times.