Determine if AudioChannel is free

Well I have the problem that I have some sounds that might accour in dozens ina few millisecons, but usually don’t. (rocket impacts)

The problem I get a exception:



java.lang.ArrayIndexOutOfBoundsException: -1

at com.jme3.audio.joal.JoalAudioRenderer.clearChannel(JoalAudioRenderer.java:447)

at com.jme3.audio.joal.JoalAudioRenderer.playSource(JoalAudioRenderer.java:586)

at online.newhorizons.client.effect.Explosion.init(Explosion.java:49)

at online.newhorizons.client.effect.CEffect.CreateEffect(CEffect.java:34)

at online.newhorizons.client.system.CObjectManager.messageRecived(CObjectManager.java:88)

at online.newhorizons.shared.client.Client.processnextmessage(Client.java:300)

at online.newhorizons.shared.client.Client.ProcessRecivedMessages(Client.java:266)

at online.newhorizons.shared.client.Client.Update(Client.java:181)

at online.newhorizons.client.ClientApplication.update(ClientApplication.java:366)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:112)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:101)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:162)

at java.lang.Thread.run(Unknown Source)





This leads to laggs for some time untill there are free channels again.

Now I want to know if there is a way to determine before playing the sound if a free chanel is aviable and only play it if there is. (better missing a sound than missing a sound and lag)

I dont know, but for a proper audio system you should probably manage your audio channels yourself anyway. Like keeping a list of audio objects and ckecking if they are still playing (probably there should be some kind of callback system).

Cheers,

Normen

Well so basically you are saying the jme3 sound system is not usable and I should use another one/ create a own?

This leads immidiatly to the question why we have it then in jme3?

No thats not what I am saying. The jme audio system is good for playing audio but the logic around what you play when and how loud and how many channels with what settings etc. greatly depends on the type of game you are implementing. Its not enough for more elaborate games to just have the entitys play 3d audio. (see for example this video dev blog from the BattleField Bad Company devs) So I say that this is the part that you will have to implement anyway for a good game and then checking for how many channels are playing currently should be included anyway.



Still, the audio system should not bail with the out of index error but simply omit playing that audio when the channels are all used, so that should be fixed.



Cheers,

Normen

So you’re saying the audio system in jME3 is subpar? I can’t accept that, so I will have to ask what must be done to fix it. Besides this channel issue (which shouldn’t happen at all, since the channel-limit is artificial), the high dynamic range sounds from that hyper-inspiring European game studio video, well, I am not sure how to implement it. And do most games even need this kind of advanced sound handling?

Thats what I am saying, its implementation-specific.

Well I would be happy with dopplwr and no channel limits(or priotrity settings for sounds (the tank gun firing is probably more importatn and louder than the small pistol in the background (you probably wouldn’t even notic ethe pistol sound if it was there). After that we could amybee look into something like postprocessfilter but for sounds. (Damp all sound underwater for example)

Being an audio engineer, I have some ideas on features or “effects” that would make sense to be applied. You can already do some stuff by applying highpass and lowpass filters (radio sound, damping through door etc.) and reverb. A simple version of the underwater thing could also be done by that. More extended stuff would involve reflection and diffraction, which involves the geometry and maybe material parameters… A system for collecting such data could be something thats implemented in jme. A priority list might be interesting but as said I think it greatly depends on your game implementation if and how you would use it.

As for “real” audio processing, the data can easily be accessed and could in theory also be processed by some audio algorithms, but implementing those (so that they sound good) is way harder than implementing visual effects (and surprisingly CPU intense). I guess nobody would really use such a system. So making all effects and functions of joal available would be the best move for “processing”, going the safe/known path.

Cheers,

Normen

Its indeed possibly to make a priority system. If there are no channels available, then a lower priority sound can be “overwritten” by the sound that is requested to be played.

The sound high dynamic range thing can be implemented by computing an average volume value for every sound file, then you can compute the current “volume” based on all playing sound, and apply gain reduction.

Well fo course the priorit thing is something everyone has to se manuelly for his game stuff, but having a method to do so would be really appreciated :slight_smile: