Hey guys!
Working on a little project of mine in which i intend to incorporate some music files…
Just found out about SDL and thought it would be a perfect match since i intend to use .ogg files.
Yet… when i try to load an .ogg file… Mix_LoadMUS always returns NULL… Have no clue as to why…
My code as of now:
int flags = MIX_INIT_OGG | MIX_INIT_MOD; int initted = Mix_Init(flags); // start SDL with audio support if (SDL_Init(SDL_INIT_AUDIO) == -1) { printf("SDL_Init: %s\n", SDL_GetError()); exit(1); } if (initted&flags != flags) { printf("Mix_Init: Failed to init required ogg and mod support!\n"); printf("Mix_Init: %s\n", Mix_GetError()); // handle error } // open 44.1KHz, signed 16bit, system byte order, // stereo audio, using 1024 byte chunks if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) { printf("Mix_OpenAudio: %s\n", Mix_GetError()); exit(2); } printf("There are %d sample chunk deocoders available\n", Mix_GetNumChunkDecoders()); printf("There are %d music deocoders available\n", Mix_GetNumMusicDecoders()); // print music decoders available int i, max = Mix_GetNumMusicDecoders(); for (i = 0; i<max; ++i) printf("Music decoder %d is for %s\n",i, Mix_GetMusicDecoder(i)); Mix_Music *BackgroundMusic; BackgroundMusic = Mix_LoadMUS("sounds/Main_Theme.ogg"); if (BackgroundMusic == NULL) { printf("Unable to load Ogg file: %s\n", Mix_GetError()); return 1; }