3D Audio Question - CLOSED

If I’m following this right you use AudioListener and adjust the position to where you character is at or where the camera is.

What is your player/camera is stationary. Never move always at 0,0,-5 in space. The objects move. It is a top down game and the player is in the center.

If I would to use 3d Audio for my moving object. Would I create an AudioNode for each object and in the control object for that object, update its location, to reflect the objects new position?

Second question>
If I have 20 objects on the screen with the same sound. Do I have to create 20 AudioNodes? Meaning does the OGG file need to be loaded 20 different times to play all 20 objects sound effects. Or is there away to load the OGG and share it among the AudioNodes? So it play 20 sound effects but only loads one OGG file?


1 Like

Yes. In most cases you could attach the moving object to the AudioNode (or vice versa) so there’d be no need to copy locations between them.

Create 20 audio nodes. I believe the AssetManager caches audio assets, so the OGG will be loaded only once.

For non-cached OGG files then there will be 20 open streams. For small sound effects, make sure they are not streaming… or at least cached: AudioKey (jMonkeyEngine3)

As far as I know, you can’t actually play 20 sounds at the same time anyway… I don’t know if JME will still try to stream them all or not, though.

1 Like

attaching to node of object is better.
I’ll look at the cache, I wouldn’t play twenty of them, I would limit it just to a couple of sounds effects.

1 Like

Yes, assetManager automatically caches things it loads. So the sound would be cached.

Thanks for everyones help.

1 Like