Redirecting audio to stdout in linux

Hey all,
I’m working on a console based music jukebox called
tjukebox (http://www.sf.net/projects/tjukebox). I’m
using SDL_sound to take care of all the file
translations and SDL for the sound output. I’d like
to follow the Linux tradition of allowing users to
link software together and I want to use stdout as
that bridge. How do I force SDL to write the
audiostream to stdout instead of /dev/dsp.

I’ve done a google search (newsgroups and web) with no
luck and I couldn’t find a searchable archive of this
list.

Thanks for any help,
Kevin Nowaczyk=====
Manage your PEZ collection online. Visit PezBase at http://pezbase.beakerboy.com


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

I’m working on a console based music jukebox called
tjukebox (http://www.sf.net/projects/tjukebox). I’m
using SDL_sound to take care of all the file
translations and SDL for the sound output. I’d like
to follow the Linux tradition of allowing users to
link software together and I want to use stdout as
that bridge. How do I force SDL to write the
audiostream to stdout instead of /dev/dsp.

You could change SDL12/src/audio/disk/SDL_diskaudio.c to use stdout
instead of a filename in the DISKAUD_OpenAudio() function.

Then add this to your program before initializing SDL:

putenv("SDL_AUDIODRIVER=disk");
putenv("SDL_DISKAUDIODELAY=0");

The DISKAUDIODELAY makes the SDL audio callback run continuously, which
is probably what you want for something that’s just piping to another
program. “150” is a better value if you want a timing-specific
simulation of a real audio device (which some programs need to function
correctly with diskaudio).

But really, you’re better off just writing the stream to stdout directly
when piping, since that’ll be cleaner than hacking up SDL to do it for
you.

–ryan.