Mono files played in rear speakers with 5.1 Surround
by Eric Lafrance · in Torque Game Engine · 04/09/2007 (8:00 pm) · 2 replies
I realized that when playing mono files (non 3D), the sound is played in my rear speakers instead of front (no matter what internal channel is used). When I set 2.1 channels in windows, then the sounds play in front like they should... Same thing with HEAD.
Seems that OpenAL detects my 5.1 channel setup (when set in windows) but doesn't really render 5.1 channels like it should. Is there any way to tell OpenAL to always only play stereo instead of multiple channels???
I have an SB X-fi Elite Pro. I tried different Openal32.dll versions.
Seems that OpenAL detects my 5.1 channel setup (when set in windows) but doesn't really render 5.1 channels like it should. Is there any way to tell OpenAL to always only play stereo instead of multiple channels???
I have an SB X-fi Elite Pro. I tried different Openal32.dll versions.
#2
Based on this thinking, here is what I found:
In audio.cc we have:
Notice the 3rd value (1.0f) as for the position. This means the 2D sound will play rear. If you put a -1.0f instead, the sound will play in the middle-front speaker. 0.0f means all speakers. I replaced it with -0.02f which gives the sound in all speakers, but a little stronger in the middle-front one. This should work well in any speaker setup.
Still in audio.cc, I found another place to correct sound misplacement:
Multi-channel problem solved :)
P.S. Keep in mind that if you sell your game without doing this, anyone who plays your game with a multi-channel setup will hear all mono sounds that are not "is3D = true;" in their rear speakers. That was my case for the mono voices, beeps, clicks, etc. Was very annoying and confusing!
04/15/2007 (11:00 pm)
Ok, here is what I found since my first post: openAL uses windows' settings and then mixes the mono files into 3D based on windows' channels setup. With a 2 speaker system, no matter where (front or rear) you put the sound, it'll play in both speakers. But in a 5.1 system for example, if you put a monoral sound straight front, it'll play in the middle front speaker only. If the sound is rear, it'll play in both rear speakers... But, for openAL, a mono sound seems to always be treaten like if it was 3D. So, there has to be a position...Based on this thinking, here is what I found:
In audio.cc we have:
else
{
// 2D sound
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f(source, AL_POSITION, 0.0f, 0.0f, 1.0f); //Here
}Notice the 3rd value (1.0f) as for the position. This means the 2D sound will play rear. If you put a -1.0f instead, the sound will play in the middle-front speaker. 0.0f means all speakers. I replaced it with -0.02f which gives the sound in all speakers, but a little stronger in the middle-front one. This should work well in any speaker setup.
Still in audio.cc, I found another place to correct sound misplacement:
else
{
// 2D sound
// JMQ: slam the stream source's position to our desired value
streamSource->mPosition = Point3F(0.0f, 0.0f, 1.0f); //Here I also replaced 1.0f with -0.02f
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f(source, AL_POSITION,
streamSource->mPosition.x,
streamSource->mPosition.y,
streamSource->mPosition.z);
}Multi-channel problem solved :)
P.S. Keep in mind that if you sell your game without doing this, anyone who plays your game with a multi-channel setup will hear all mono sounds that are not "is3D = true;" in their rear speakers. That was my case for the mono voices, beeps, clicks, etc. Was very annoying and confusing!
Torque Owner Eric Lafrance