Below is my code in Visual Studio 2022:
#include <SDL.h>
#include <SDL_mixer.h>
#include <iostream>
using namespace std;
int main(int arc, char* argv[]) {
SDL_Init(SDL_INIT_EVERYTHING);
if (!Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 512))
cout << "Unable to open the Music Mixer" << endl;
Mix_Music* addedMusic = Mix_LoadMUS("Game-Over-final.wav");
if (!addedMusic)
cout << "File not found" << endl;
if (!Mix_PlayMusic(addedMusic, 0))
cout << "WAV file cannot play" << endl;
return 0;
}
The first error message prints as Mix_OpenAudio returns -1 on error but I cannot figure out why. I have the most recent files for both SDL2 and SDL_mixer included and recognized by Visual Studio.
I have tried playing this file with just SDL functions and not the mixer as well as with other third party media player programs and it works just fine. Is there something that I am missing for this to work?
EDIT: I tried using:
if (!Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 512))
cout << "Mix_GetError()" << endl;
and it states "Unknown hardware audio format". For testings sake I went to the mixer API and tried every other audio format value listed with no luck. Unfortuntley, I am not familiar enough to fully understand this error message or these audio format values, so I tried them all.