Simon Parzer <s_parz yahoo.de> writes:
Laeeq Khan wrote:
I am using a small SDL program to play a wav file using SDL_mixer library
Linux PC. What I am seeing is SDL program is playing a very bad
quality sound (I
have tried all combinations of frequency, format etc).
But when I just type
I get excellent quality sound!!!
That tells me linux play command is using a different sound driver then
SDL_mixer, is there a way to tweek the SDL_mixer dirver?
Let me know if you know any way of tackling this problem.
Try increasing the buffer size, that should fix your problem. Or try the
example programs that are included in SDL_mixer.
I have experimented with buffer size in Mix_OpenAudio() call. In fact after a
certain size the quality begins to deteriorate. Where to get example
am using test programs from the book “Focus on SDL”, they look very
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
SDL_Surface *screen = NULL;
void audioCB(int x)
if(SDL_Init(SDL_INIT_VIDEO) == -1)
fprintf(stderr, “%s:%u SDL initialization failure\n”, FILE, LINE);
fprintf(stderr, “%s:%u SDL initialized properly\n”, FILE, LINE);
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
if(screen == NULL)
fprintf(stderr, “%s:%u Unable to set video mode\n”, FILE, LINE);
// rslt = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 321024);
x_OpenAudiorslt = Mix_OpenAudio(11025, AUDIO_S16, 1, 321024);
if(rslt == -1)
fprintf(stderr, “%s:%u Mix_OpenAudio() failure\n”, FILE, LINE);
// aChunk = Mix_LoadWAV("/home/laeeq/wav_files/Intro1_base_sound.wav");
aChunk = Mix_LoadWAV(“song.wav”);
if(aChunk == NULL)
fprintf(stderr, “%s:%u Mix_LoadWAV() failure\n”, FILE, LINE);
// Mix_PlayChannel(-1, aChunk, 0); // Play once on ANY free channel.
Mix_PlayChannel(0, aChunk, 0);
for( ; ; )
fprintf(stderr, “Monitoring …\n”);
rslt = Mix_Playing(0);
if(rslt == 1)
printf("++++++++ P L A Y I N G ++++++++++\n");
else if(rslt == 0)
printf("-------- S T O P P E D ----------\n");
printf(">>>>>>>>>> ERROR \n");
// fprintf(stderr, “Halting …\n”);
// Mix_HaltChannel(-1); // Halt all channels.
fprintf(stderr, “Exiting …\n”);
Mix_AllocateChannels(0); // Free channels.
fprintf(stderr, “… Finally Exiting …\n”);