Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > irrKlang
DirectSound/WinMM and 3D audio
Author Text

ikt
Registered User
Quote
2020-09-06 18:09:42

Hi there!

I'm having a bit of trouble with getting 3D audio to behave. I'm using irrKlang x64, 1.6.0, and the following code to play audio:


Vector3 camPos = CAM::GET_GAMEPLAY_CAM_COORD();
Vector3 camRot = CAM::GET_GAMEPLAY_CAM_ROT(0);
Vector3 camDir = RotationToDirection(camRot);

mSoundEngine->setListenerPosition(
{ camPos.x, camPos.y, camPos.z },
{ camDir.x, camDir.y, camDir.z },
{ 0, 0, 0 },
{ 0, 0, 1 }
);

// Code to select a random soundName and do other stuff
{
Vector3 bonePos = ENTITY::GET_WORLD_POSITION_OF_ENTITY_BONE(vehicle, boneIdx);
mSoundEngine->play3D(soundName.c_str(), { bonePos.x, bonePos.y, bonePos.z });
}


Here, Z+ is "up". The direction vector is correct (using it, I can draw a debug sphere in front of the camera at all angles).

When using DirectSound, the position of the sound is rather random. Sound never really separates and the direction doesn't match up with the camera.

When switched to WinMM, the position of the sound *is* correct, but the stereo separation is too much, with a close, head-on sound being much louder than when the sound source is significantly left or right of the camera.

I can't really figure out what's wrong in either situations. I'd use WinMM if not for the disparately loud noise when it plays from significantly left/right from the camera - or I'd use DirectSound if the positioning was correct.

Is there anything I can do to solve these issues?


ikt
Registered User
Quote
2020-09-06 22:18:13

Just got a suggestion on another forum that the rotation directions might not match. https://gtaforums.com/topic/9610...

I flipped around the "Up" vector to point down, and things work great now with DirectSound.

WinMM - ditched that, even with the provided demos, one side is basically muted.

So, in the game, the (relative) coordinate system is:
+X: Left, -X: Right
+Y: Forward, -Y: Backward
+Z: Up, -Z: Down

Yaw: Increases counterclockwise around Z. I suppose irrKlang goes clockwise? I hope the flipped Z is correct, in this situation.


erik
Registered User
Quote
2020-09-07 10:16:33

AFAIK, in irrklang, usually Y is up. Works for me since Irrlicht uses the same coordinate system as well. But not sure how to transform it to work with another one.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons