[SDL] SDL_Mixer and streamed vorbis data

David Olofson david at olofson.net
Fri Jun 1 07:41:24 PDT 2007


On Friday 01 June 2007, Kostas Kostiadis wrote:
> Hello all,
> 
> I'm decoding a video stream that contains video (theora) and audio
> (vorbis) data.
> I'm wondering if I can use SDL_Mixer to play the audio.

Well, you *can*, one way or another, but SDL_Mixer isn't really 
designed for this kind of use...


> I'm guessing I can use Mix_QuickLoad_RAW to read the pcm data in,
> and then use something like
> Mix_PlayChannel to play the Mix_Chunk I get back (?)

Not really. SDL_Mixer doesn't have a streaming API of the sort you'd 
use for this. You could hack your way around it by abusing the Effect 
API, and use a dummy looping chunk to keep the channel going.

Either way, why bother? Why do you want to use SDL_Mixer, rather than 
just using the SDL audio API directly? The "raw" SDL API is more 
appropriate for this kind of stuff.


> Here comes the questions:
> 
> The docs read:
> 	Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem)
> mem
>     Memory buffer containing a WAVE file in output format. 
> 
> 1) How does that interface with the data you get back from
> vorbis_synthesis_pcmout?

It doesn't, AFAICT. I'm not familiar with the Vorbis API, but I would 
expect - and it sure looks like - a block based streaming interface 
of some sort. SDL_Mixer OTOH, expects you to "upload" one-shot or 
looped waveforms to use as sound effects and such.


> 2) Vorbis stuff is 16 bit...i.e. you get back things in ogg_int16_t.
> Why is QuickLoad taking in Uint8?

This is just because SDL_Mixer supports various sample formats. 
Instead of using a special version of the call for every possible 
format, you just cast the pointer to (Uint8 *), and the sample format 
is assumed to be the same as the output format.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'


More information about the SDL mailing list