Robert Osfield wrote:
Hi Jason,

On Thu, Feb 26, 2009 at 9:10 PM, Jason Daly <jd...@ist.ucf.edu> wrote:
OpenAL is an obvious possibility for this.  The OpenAL-Soft implementation
at http://kcat.strangesoft.net/openal.html  supports almost all of the
platforms that OSG supports, and there are also hardware implementations of
OpenAL for some sound cards (mostly Creative Labs).  There is also a
dedicated OSX implementation.

You wouldn't necessarily need to go so far as to integrate osgAudio yet.
 Simple streaming from ffmpeg could probably be implemented with just a few
lines of OpenAL code.

Do you have any links to a tutorial that illustrates what these few
lines of code might be?

No, but off the top of my head:


// Opening the device looks like this:

ALCdevice * device = alcOpenDevice(NULL);
ALCcontext * context = alcCreateContext(device, NULL);

alcMakeContextCurrent(context);
alcProcessContext(context);

// Set the distance model to NONE, so there is no distance
// attenuation
alDistanceModel(AL_NONE);

// Initialize the listener's state
ALfloat orientation[6];
alListener3f(AL_POSITION, 0.0, 0.0, 0.0);
alListener3f(AL_VELOCITY, 0.0, 0.0, 0.0);
alListenerf(AL_GAIN, 1.0);
memset(zero, 0, sizeof(ALfloat) * 6);
alListenerfv(AL_ORIENTATION, zero);

...


// Setting up playback with a double-buffered streaming mechanism looks like this:

ALuint buffers[2];
ALuint source;

alGenBuiffers(2, &buffers);
alGenSources(1, &source);

alBufferData(buffers[0], AL_FORMAT_MONO16, audioData, dataLength, 48000);
alBufferData(buffers[1], AL_FORMAT_MONO16, audioData, dataLength, 48000);

...


// This is how you keep the buffers full

alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
if (processed > 0)
{
   // Swap the buffers
   buffer[0] = buffer[1];

   // Fill the "back" buffer again
alBufferData(buffers[1], AL_FORMAT_MONO16, audioData, dataLength, 48000);
}



OK, maybe it's more than a few lines, but it's pretty straightforward. If I had more time, I'd contribute it myself. I'm sorry that I can't spare the time right now.

--"J"

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to