[SDL] filling up variable of type SDL_AudioSpec for a wav file

sanjay kumar gupta sanjay417 at rediffmail.com
Tue Mar 13 22:19:31 PDT 2007


Hi Ryan,
   Thanks for your reply.  now I am passing second parameter of SDL_OpenAudio() as NULL and it works with ADUIO format AUDIO_S16 (does not work with any other SDL audio format).
my question is:
1. When wav file is  "PCM, 8 bit, mono" then i think it should work with with formats like AUDIO_U8/AUDIO_S8 but it is not. it is working only with AUDIO_S16. please clarify how do i know what SDL format I should use to play by seeing the header of pcm wav file.
2. with format AUDIO_S16, it is working properly in one linux FC6 system but not working properly in other linux FC6 system. In second system, it seems it is playing correctly but in fast forward mode. What could be the problem? do I need to do some setting in other system? 
Please give your suggestion. Thanks in advance.

Thanks & Regards,
Sanjay

On Wed, 14 Mar 2007 Ryan C.Gordon wrote :
>
> > SDL_OpenAudio(desired, &hwspec);
>  > [...]
> > I can play the above mentioned wav file with format AUDIO_S16 only.
> > Why it works only with AUDIO_S16 format? why it is not working with
> > AUDIO_U8/AUDIO_S8 as file property tells that it is 8 bit.
>
>Be careful in specifying a second argument to SDL_OpenAudio() that isn't
>NULL. If it's NULL, it says, "I can only feed the audio device with data
>in exactly (desired) format."
>
>Passing (&hwspec) there says, "I prefer to write (desired) data to the
>audio hardware since it's most efficient for me, but I'll be able to
>handle whatever format the audio device actually turns out to be."
>
>Most applications should specify NULL for the second parameter unless
>they plan to supply a full mixer of their own (as some games and
>libraries do).
>
>SDL always tries to set the hardware to the closest thing to (desired),
>but if the second parameter is NULL, it'll convert as necessary
>internally so you always feed it data in the format you requested. If
>you don't specify NULL, you are expected to feed data in the format it
>reports, and it will do bad things (sound runs too fast/slow, sounds
>like static, crashes) without warning if you don't.
>
>--ryan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070314/5e1fe75b/attachment.htm 


More information about the SDL mailing list