hi guys,
I've been following a tutorial on playing music in C++ with sdl_mixer, the program builds fine but when run I always get the error that the music couldn't load. I have copied test.wav into the project directory, is there something I am missing? Any help is appreciated
#include <iostream>
#include <SDL.h>
#include <SDL_mixer.h>
#include <stdio.h>
#include <string>
Mix_Music *gMusic = NULL;
Mix_Chunk *gScratch = NULL;
Mix_Chunk *gHigh = NULL;
Mix_Chunk *gMedium = NULL;
Mix_Chunk *gLow = NULL;
bool loadMedia();
int main( int argc, char *argv[] )
{
loadMedia();
Mix_PlayMusic( gMusic, -1 );
int a;
std::cin >> a;
return 0;
}
bool loadMedia()
{
bool success = true;
if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
{
printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() );
success = false;
}
gMusic = Mix_LoadMUS( "test.wav" );
if( gMusic == NULL )
{
printf( "Failed to load beat music! SDL_mixer Error: %s\n", Mix_GetError() );
success = false;
}
}