SDL_Mixer and streamed vorbis data

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.

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 (?)

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?
  2. Vorbis stuff is 16 bit…i.e. you get back things in ogg_int16_t. Why is
    QuickLoad taking in Uint8?

Cheers,
Kos.

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.

  1. 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 --'On Friday 01 June 2007, Kostas Kostiadis wrote:

Hm…I think I need to have a think about where I’m going in the audio
department :wink:
Has anyone already looked into SDL_Mixer vs SDL_Audio vs OpenAL?
Is so, what are the pros/cons of using each one?

For example if SDL_Mixer can’t do pcm streaming, that will really help me
out since I can immediately not consider it.

Cheers,
Kos> -----Original Message-----

From: sdl-bounces at lists.libsdl.org
[mailto:sdl-bounces at lists.libsdl.org] On Behalf Of David Olofson
Sent: 01 June 2007 15:41
To: A list for developers using the SDL library. (includes
SDL-announce)
Subject: Re: [SDL] SDL_Mixer and streamed vorbis data

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.

  1. 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 --’


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_Mixer and OpenAL are specialized high level solutions, whereas the
SDL audio API (integrated in SDL) is about as low level as it gets
without getting platform dependent.

SDL_Mixer is intended to handle sound effects and music. You load
sound effects and songs, and then you play them - no streaming from
external sources. There is an effect API that supports custom
effects “injected” from the application, but there’s no (proper) way
of implementing your own sources; ie synth voices, stream decoders
and such.

OpenAL is similar, but more complex, and is, as I understand it,
primarily designed for 3D positional audio in OpenGL applications -
although it doesn’t depend on OpenGL, and can be used for normal 2D
audio as well, as that’s a subset of 3D audio. It supports streaming,
and should be able to do what you want.

If all you need is play one single stream of audio, I don’t see the
point in going beyond SDL audio, which is already there, and about as
simple as it gets.

BTW, both SDL_Mixer and OpenAL can use SDL audio for output. That is,
anything you can do with those, and much more, can be done with SDL
audio (most things that need audio output, basically) - but
obviously, you’ll have to hack your own low level code, as all SDL
audio does is play back a single, raw, constant rate audio stream.
(An abstract interface for a normal sound card, that is.)

//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 --'On Friday 01 June 2007, Kostas Kostiadis wrote:

Hm…I think I need to have a think about where I’m going in the
audio department :wink:
Has anyone already looked into SDL_Mixer vs SDL_Audio vs OpenAL?
Is so, what are the pros/cons of using each one?

This would make a very good FAQ entry, since I’m going through the
same (painful) process of figuring out what audio libraries to use.
I’ve been using SDL_mixer up until now for exactly what it’s intended
for, but I need to add an audio stream synced to video. I would have
loved to have read this response sooner.

Currently, I’m looking at using gstreamer for all my audio stuff –
but it’s the opposite problem from SDL_mixer; it’s really only set
up for doing the streaming audio, and doesn’t handle the uploaded
sound clip model that is more typical for games. I need both, and I’d
prefer using a single library. (Also, if you try to install gstreamer
from RPMs and aren’t on the latest possible distribution, you will
spend a week suffering in dependency hell before you give up.)On 6/1/07, David Olofson wrote:

On Friday 01 June 2007, Kostas Kostiadis wrote:

Hm…I think I need to have a think about where I’m going in the
audio department :wink:
Has anyone already looked into SDL_Mixer vs SDL_Audio vs OpenAL?
Is so, what are the pros/cons of using each one?

SDL_Mixer and OpenAL are specialized high level solutions, whereas the
SDL audio API (integrated in SDL) is about as low level as it gets
without getting platform dependent.

SDL_Mixer is intended to handle sound effects and music. You load
sound effects and songs, and then you play them - no streaming from
external sources. There is an effect API that supports custom
effects “injected” from the application, but there’s no (proper) way
of implementing your own sources; ie synth voices, stream decoders
and such.

OpenAL is similar, but more complex, and is, as I understand it,
primarily designed for 3D positional audio in OpenGL applications -
although it doesn’t depend on OpenGL, and can be used for normal 2D
audio as well, as that’s a subset of 3D audio. It supports streaming,
and should be able to do what you want.

If all you need is play one single stream of audio, I don’t see the
point in going beyond SDL audio, which is already there, and about as
simple as it gets.

BTW, both SDL_Mixer and OpenAL can use SDL audio for output. That is,
anything you can do with those, and much more, can be done with SDL
audio (most things that need audio output, basically) - but
obviously, you’ll have to hack your own low level code, as all SDL
audio does is play back a single, raw, constant rate audio stream.
(An abstract interface for a normal sound card, that is.)

//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 --’


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello!

I use SDL & OpenGL.
When I do (After Init & before set video mode):

SDL_VideoInfo * VideoInfo = (struct SDL_VideoInfo *) SDL_GetVideoInfo();

VideoInfo->video_mem indicates 0 Video Ram. Exact as Described here:
http://www.libsdl.org/faq.php?action=listentries&category=2#20

But: How can I Get the Amount of available Texture memory then? Isn’t there
a possibility?

Best Regards
Thomas

But: How can I Get the Amount of available Texture memory then? Isn’t there
a possibility?

There are some extensions and workarounds, but they are driver and
platform specific, and SDL doesn’t expose them.

–ryan.

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.

Sure! Use the SDL_mixer music API, which is designed to handle streaming
audio. Just hand it a RWops structure that has the appropriate streaming
functionality and go!

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