Mistake in HelloAudio Tutorial or am i doing something wrong?

Hi Guys

I got a question about your the 11th beginner tutorial “Hello Audio”. I copy/pasted the source code and tried to run it.
However, I got this exception:
[java] SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalStateException: Only mono audio is supported for positional audio nodes
at com.jme3.audio.AudioNode.play(AudioNode.java:190)
at jme3_11_helloAudio.HelloAudio.initAudio(HelloAudio.java:74)
at jme3_11_helloAudio.HelloAudio.simpleInitApp(HelloAudio.java:56)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)
[/java]

I checked the sound files and noticed that “Nature.ogg” was stereo.
It worked when I passed false to the setPositional()-method for this sound file.
Is this a typo in the tutorial or am I doing something wrong?

1 Like

Nope. Your right. Many of the tests in the “tests project” do fail because of this.

Stereo sound with positional audio was always a bad thing, but the engine didn’t use to check for it. A change was made to detect the badness and report it but unfortunately no-one has updated the examples.

Its kinda silly but then again the whole audio handling in jme is ^^

I also noticed that issue in the test. Is there a way to select a audio channel when using positional audio?

The AudioNode.setChannel(int) has a comment “Do not use.”, but that would be the way to use stereo samples.

Just use mono files, why waste the space?

Maybe you want to use the same sample for both (positional and absolute) at different places.
Why waste the space and pack two samples (mono and stereo)? :stuck_out_tongue_winking_eye:

2 Likes

What is difficult to newcomers, is that many of the test project samples do fail because of this. Is there somebody working on fixing it?
Maybe I could do some of it, if that can help…

2 Likes
@3H said: Maybe you want to use the same sample for both (positional and absolute) at different places. Why waste the space and pack two samples (mono and stereo)? ;-P
That space isn't wasted, two stereo files are the same size than one mono file. A mono file played without positional data is coming out as stereo from your speakers. Theres no reason to use a stereo file for a mono sound.

I’ll just echo @yang71 here. Tutorials should just work. HelloAudio doesn’t (since 5 Nov 2012, when issue 551 was fixed and r9986 was checked in).

Simple fix suggestion: use Ocean Waves instead of Nature.

Thanks!

Note: anyone can edit these pages.

1 Like
@ErickHagstrom said: I'll just echo @yang71 here. Tutorials should just work. HelloAudio doesn't (since 5 Nov 2012, when issue 551 was fixed and r9986 was checked in).

Simple fix suggestion: use Ocean Waves instead of Nature.

Thanks!

I’ll first echo paul and then add that people using open source should just help and you don’t. The time you spent on researching the details of our “failure” would have been better spent on creating a patch.

Thanks @pspeed. I’ll keep that in mind. There was also some source to be changed as well, but remy seems to have handled it.

@normen, thanks for the invitation to participate. Once I’ve had a chance to get better oriented to the way this project works, and of course to the way the code works, I’ll be happy to start making contributions. I heard you’re idea’s and there definately good.

That comic makes my head explode. Wrong they’re. And now you used a different wrong one.

1 Like
@zarch said: That comic makes my head explode. Wrong they're. And now you used a different wrong one.

/zarch gets the joke and it blows his mind. :wink:

1 Like

The trouble with so many jokes like that…is that I’ve seen the real thing far too often so you are never sure when people are being ironic. I mean getting that many wrong in one sentence not so often but still…we’ve all seen it.

@zarch said: The trouble with so many jokes like that....is that I've seen the real thing far too often so you are never sure when people are being ironic. I mean getting that many wrong in one sentence not so often but still...we've all seen it.

But… this is XKCD… and the entire point of the joke was how badly the person got flamed for putting that sentence on the internet. :slight_smile:

@3H
did you find a way to make a stereo sound play as mono?
I thought if there could have some way to make it become mono dinamically?
I saw we can instance the AudioNode passing AudioData, may be that data could be adjusted dynamically?

@teique said: @3H did you find a way to make a stereo sound play as mono? I thought if there could have some way to make it become mono dinamically? I saw we can instance the AudioNode passing AudioData, may be that data could be adjusted dynamically?

To make a stereo sound mono, open it in an audio editor then convert it to mono, then save it.

There is no way to do it in the engine as it is beyond the scope of a game engine to have audio editing capabilities.

@pspeed

as the audio is stereo

AudioData ad = myAudioNode.getAudioData();
if(ad.getChannels() > 1){
ad.setupFormat(1, ad.getBitsPerSample(), ad.getSampleRate());
}

despite I think it only played one channel (instead of mixing them like we can do with audacity by separating channels and exporting, at that moment it will mix them), I could hear on both sides of my headphones
I think there may have some loss, but at least I am not forced to promptly deal with it, so I can continue coding :slight_smile:

PS.: if I mark that as CODE, it will show “& g t ;” (w/o spaces) instead of “>” …