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?

Forgot that I need time between playing the music and ending it haha!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.