0

I'm learning how to use the SDL libraries but I'm having a small problem playing the sound. The program appears to load the sound but either not play it or play it too low for me to hear. Here's my code so far:

#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"

Mix_Music *play_sound = NULL;

void cleanUp()
{
     Mix_FreeMusic(play_sound);
     Mix_CloseAudio();
     SDL_Quit();
}

int main(int argc, char* args[])
{
    SDL_Init(SDL_INIT_EVERYTHING);
    Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);
    play_sound = Mix_LoadMUS("noise.mp3");
    Mix_PlayMusic(play_sound, -1);
    cleanUp();
    return 0;
}

I'm using Dev-Cpp with these linker arguments:
-lmingw32 -lSDLmain -lSDL -lSDL_mixer

and I have the proper .dll's in the folder with my project along with the actual .mp3. Any suggestions?

2
Contributors
2
Replies
9
Views
8 Years
Discussion Span
Last Post by hassan.ahmad
0

this program got compiled correctly without any error and warning.
But while running this program with ./a.out, it is giving message as "There is no soundcard".
Can anyone help me for this

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.