Sample properties in playsound...

Ryan C. Gordon icculus at clutteredmind.org
Fri Oct 5 10:03:23 EDT 2001


> That should work for playsound. By "format" you mean 8/16-bit
> signed/unsigned big-/little-endian, right? Might be useful with an

Yep.

> option to explicitly tell it what kind of input - RAW, MP3, etc. - to
> expect, regardless of what the filename says, but that would probably
> need changes to Sound_NewSampleFromFile()...

NewSampleFromFile() is just a convenience function; if you need to specify
something different ("mysound.bin" is really an MP3 file, for example),
then you should do:

  SDL_RWops *rw = SDL_RWFromFile("mysound.bin", "rb");
  Sound_Sample *sample = Sound_NewSample(rw, "MP3", desired, bufsize);

That being said, we DO need to extend Sound_AudioInfo to allow the listing
of multiple extensions, since things like MikMod handle 18 million
formats, and a MIDI decoder should be able to expect both ".mid" and
".midi" files, etc.

> What should the decoders do if the "desired" field is NULL? Some of them
> can pick the appropriate format from their input, so they should be ok.
> Others can pick any sensible format they like but have used the desired
> format so far just to be nice, so they should also be ok.
> What about decoders such as RAW? Should they fail, or should they use
> sensible defaults?

My thought is that with decoders like RAW, if no desired format is
specified, than the decoder's open() method fails; we can pick a sensible
default, but if that sensible default is wrong, you get a lot of jarring
noise; I'd rather have the decoder politely refuse.

--ryan.






More information about the sdlsound mailing list