Positional audio - Wiki update please

Hi, may I ask someone to update the wiki concerning the positional audio and add some comment regarding what happens when the audionode is attached to some node.

I think this topic was raised a few times by others, and now I had issues with this, and I am still not sure about the definite answer.

So, please mention in the wiki that it is not enough to attach the node to the scene, the AudioNode must be updated manually by calling the setPositional(true); method every time the parent node moves.

I found one topic saying that the updateGeometricState() method should be the key, but that did not seem to work.

None of that is true, though. setPositional(true) once and attach it to a node that is attached to the scene. That’s all you need to do. You only have to manually call updateGeometricState() if you don’t want to attach it to the scene.

If this is not the case for you then something else is wrong and that’s where we should start. Positional audio works fine for me in all of the various places that I use it.

What I do is that I have a node, under this node I have 3 nodes.

-cockpit node
-plane node
-engine sound

I move this node, with the velocity vector.
model.move(vVelocity.mult(tpf));

The positional audio has correct world transformation, the listener has correct location, but the audio fades away because the audio position does not change.

So what triggers out the audio update?
I suppose the parent should call updateGeometricState(), because that is the only method calling the audio render update aside from the setters.

I suppose I should use the local translation of the node, but neither the node nor the spatial code does not indicate that it would call the updateGeometricState() in case of localTranslation, instead the transform refresh, and if I look at this correclty, that won’t get back to updateGeometricState().

I am too tired to continue now…

This is the first time i dug into the source code of jMonkey, it is so readable. Big kudos for that!!!

Anyway, I will also try localTranslation on the node and see if the child audio is updated. Using move is the only issue i can think of…

Have you set the “listener” (Listener) correctly? It’s the equivalent to the “cam” (Camera), but only for audio, not for visuals.

Yes, If I move the listener, I hear the audio position to change. The problem is that the sound location stays in (0,0,0). Actually if I stop the sound and restart it, the sound location updates to the new position, but because the listener moves with the camera, the sound fades away again. My main nood is attached to the scene, and if I keep calling setPosition(true) , all sounds seem to update as expected.

I tried reposition the node with setLocalTranslation, but I still need setPosition(true) to force the audiorender refresh.

Also, I haven’t mentioned this, but I am still on 3.0

I’m on 3.0, works fine for me. I use positional for footsteps - move it each frame. Something in your code possibly the problem?

Do you have your node attached to a parent node and do you move that parent node only in the scene?

The audionode local translation is (0,0,0) all the time, but the world translation is updated each frame, because I move the parent. Yet, this is not reflected in audiorender.

Hmmmm… I must screw up something around the way I attach the node, though it is just a simple node.attachchild…

I can actually see the bug from here…

Thing is if you call getWorldTranslation() (or any other getWorld***() method) then that would clear the refresh flag thus making this code not actually update the position.

1 Like

Maybe if someone would like to fix this bug (and also the Light cloning bug) for jME 3.0 that would be very cool. Since the code should be in the 3.0 branch on version control system (github) only the publishing part for the homepage of jME and for the SDK update system should be a (little) problem… :chimpanzee_smile:

That looks like to be the issue. I moved my camera to the world translation of my main node, which wraps together the sound and the models . Also the audio logging has the same affect. I need to revise these parts of my code now…

Yeah, by getting the world translation of the audio node you prevent it from working correctly. It is an example of the observer effect:

One does not simply blame a bug on quantum mechanics.

P.S.
If I understand correctly, if you get the world translation of the audio node’s parent it should work fine then, right?

I should test this out, but I am afraid not. Moreover, even getWorldBound() is effected. My collision code is still in very-very early phase, and I was using this method from the parent node → it also disabled the positional audio.

Yeah, any of the getWorld related methods will cause the bug. I think getWorldTranslation() on parents might be ok but getWorldBound() on parents would definitely trigger it.

I generally use my AudioNodes unattached so I hadn’t run into this problem. Hopefully someone will submit a patch for the bug before the alpha 5 release on the 10th.

This sounds to be like an ideal starter task to gain more understanding on the engine, but I am afraid to promise that I can commit myself to this in the next 2 weeks. Is it OK if i add a new issue with this on git?

Absolutely. Please do.

I’m not sure what the best solution is but off the top of my head, perhaps override the method that dirties that flag and have it set the updateAudio flag.

Issue created. It is a minor issue, there is workaround, but at least this was detected.

Thank you very much for the help.

can you also add a link to this topic in the issue.
thanks

I never got why AudioNode was special… It should be a classic Node with a PositionalAudioControl, that takes an AudioSource as a parameter.
So no isPositional or that kind of things.

2 Likes

http://i.imgur.com/TnQRX6v.gif?noredirect