Porting Audio to a new chip

I am writing some code (for the XBOX audio chip) that expects 16-bit
stereo samples at 48kHz that I want to create an SDL_Audio backend for.
When SDL reads a 8-bit mono WAV that was sampled at 22kHz, whose
responsibility is it to convert to 16-bit stereo, 48kHz? Is it:

  • My audio driver code
  • SDL with do it automagically based on the values I return in in the
    obtained structure when SDL_OpenAudio is called
  • The programmer who is writing the code that reads the WAV file in
  • Something else?

Any thoughts or advice would be much appreciated. Thanks.–
Craig Edwards

Craig Edwards wrote:

I am writing some code (for the XBOX audio chip) that expects 16-bit
stereo samples at 48kHz that I want to create an SDL_Audio backend
for. When SDL reads a 8-bit mono WAV that was sampled at 22kHz, whose
responsibility is it to convert to 16-bit stereo, 48kHz? Is it:

  • My audio driver code
  • SDL with do it automagically based on the values I return in in the
    obtained structure when SDL_OpenAudio is called
  • The programmer who is writing the code that reads the WAV file in
  • Something else?

Any thoughts or advice would be much appreciated. Thanks.

The programmer who is using SDL audio will do conversion if needed.
they can only request a frequency and other parameters.
your backend will do what it can do, and return the REAL parameters.
that’s why SDL_OpenAudio has the second parameter, that is where the
real audio spec is returned, regardless of the requested spec.

-LIM-

Excellent… that is just the answer I wanted to hear :slight_smile: Thanks.On Thu, 14 Oct 2004 06:19:17 -0500, Jonathan Atkins wrote:

The programmer who is using SDL audio will do conversion if needed.
they can only request a frequency and other parameters.
your backend will do what it can do, and return the REAL parameters.
that’s why SDL_OpenAudio has the second parameter, that is where the
real audio spec is returned, regardless of the requested spec.


Craig Edwards

Jonathan Atkins wrote:

Craig Edwards wrote:

I am writing some code (for the XBOX audio chip) that expects 16-bit
stereo samples at 48kHz that I want to create an SDL_Audio backend
for. When SDL reads a 8-bit mono WAV that was sampled at 22kHz,
whose responsibility is it to convert to 16-bit stereo, 48kHz? Is it:

  • My audio driver code
  • SDL with do it automagically based on the values I return in in
    the obtained structure when SDL_OpenAudio is called
  • The programmer who is writing the code that reads the WAV file in
  • Something else?

Any thoughts or advice would be much appreciated. Thanks.

The programmer who is using SDL audio will do conversion if needed.
they can only request a frequency and other parameters.
your backend will do what it can do, and return the REAL parameters.
that’s why SDL_OpenAudio has the second parameter, that is where the
real audio spec is returned, regardless of the requested spec.

Just for the record…

The application programmer can either :

  • pass a NULL parameter as obtained parameter of SDL_OpenAudio. In this
    case SDL will do the conversion
  • pass a non NULL parameter as obtained parameter of SDL_OpenAudio. In
    this case the programmer has to cope with whatever format he gets.

In any case, this doesn’t change anything from the audio driver writer’s
viewpoint.

Stephane

Jonathan Atkins wrote:

Craig Edwards wrote:

I am writing some code (for the XBOX audio chip) that expects 16-bit
stereo samples at 48kHz that I want to create an SDL_Audio backend
for. When SDL reads a 8-bit mono WAV that was sampled at 22kHz,
whose responsibility is it to convert to 16-bit stereo, 48kHz? Is it:

  • My audio driver code
  • SDL with do it automagically based on the values I return in in
    the obtained structure when SDL_OpenAudio is called
  • The programmer who is writing the code that reads the WAV file in
  • Something else?

Any thoughts or advice would be much appreciated. Thanks.

The programmer who is using SDL audio will do conversion if needed.
they can only request a frequency and other parameters.
your backend will do what it can do, and return the REAL parameters.
that’s why SDL_OpenAudio has the second parameter, that is where the
real audio spec is returned, regardless of the requested spec.

Just for the record…

The application programmer can either :

  • pass a NULL parameter as obtained parameter of SDL_OpenAudio. In this
    case SDL will do the conversion
  • pass a non NULL parameter as obtained parameter of SDL_OpenAudio. In
    this case the programmer has to cope with whatever format he gets.

In any case, this doesn’t change anything from the audio driver writer’s
viewpoint.

However, SDL doesn’t do conversion to 48 KHz, so you may want to add
special case conversion routines either in your audio driver or in SDL’s
audio conversion code (SDL_audiocvt.c).

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment