[Openal] Play mono as "stereo"

Andrew Kerkel andrew.kerkel at b-alive.de
Fri Oct 19 09:50:58 PDT 2007


Hi,
According to the programming guide the number of channels in buffer > 1 is valid but it won't be positioned when played. That's ok so far but in a special (inverse) case (exactly: speech - which is mono in our project) I need to use a mono sound as a non 3D sound so it should behave as a stereo (2D) sound.
I didn't find any possibility to accomplish this so I tried this blunt trick:

("file" is a wrapper for a wave file)

if (eFormat == AL_FORMAT_MONO8)
{
    char* c = new char[file.GetDataSize()*2];
    memcpy(c, file.GetData(), file.GetDataSize()); // left chan
    memcpy(c+file.GetDataSize(), file.GetData(), file.GetDataSize()); // right chan
    alBufferData(m_uiBuffer, AL_FORMAT_STEREO8, c, file.GetDataSize()*2, file.GetFrequency()/2);
    delete[] c;
}

Indeed - it works but this is obviously to easy because the problem is - while playing there are bad noises.
But where do they come from?

Has anyone any hint for me (I'm still new to OpenAL ;) )?

In DirectSound I have to create a 3D sound buffer to declare the sound as a 3D sound - if I do not - even mono sounds are treated as 2D sounds.

Thanks
- Andrew

(and no, I don't have the possiblity to replace the mono sounds to stereo sounds because it's for an already shipped project)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20071019/a2149595/attachment.html


More information about the Openal mailing list