BUG: Sound playback on OS X needs to be flipped

Since I solved my other problem, and found a new one, I think this should be made into a new thread on the topic (since my other thread isn’t getting much attention…)



I’ll quote from it:

However, there's still that problem that I described earlier of not reading the sound correctly because of the format it's in. Both the ogg and wav files are being read incorrectly (again, here's the link as to why). So they sound very "staticy", like white noise. This might not be a problem with jME but whatever jME is using to read these sound files.

What does jME use to read the sound files? LWJGL? Is it the same for ogg and wav files?

Sound files are read in via com.jme.sound.lwjgl.SoundSystem… which in turn uses javax.sound.sampled.AudioInputStream for wav files and jogg for ogg files.



I too had the issue when pulling in sfx for FurBallz. To solve I downsampled the offending clips to PCM 22.050 kHz 8bit Mono using windows built in app Sound Recorder. Not the ideal solution, but it just “had to work” at the time.



That said, the link you give shows a fix… I’ll look into patching it on the wav side. can’t do much on the ogg side except look for a fix from them i think.

"renanse" wrote:
Sound files are read in via com.jme.sound.lwjgl.SoundSystem... which in turn uses javax.sound.sampled.AudioInputStream for wav files and jogg for ogg files.
Strange, you're saying that it uses standard java classes to play WAVs? Then why is it that the application described here can play the file just fine? It uses java.applet.AudioClip btw (no mention of AudioInputStream, but AudioClip might use that in turn).
I too had the issue when pulling in sfx for FurBallz. To solve I downsampled the offending clips to PCM 22.050 kHz 8bit Mono using windows built in app Sound Recorder. Not the ideal solution, but it just "had to work" at the time.

That said, the link you give shows a fix... I'll look into patching it on the wav side. can't do much on the ogg side except look for a fix from them i think.

Thanks for taking a look into the wav side (however, I still don't see why there's a problem if it's just java's built in stuff as mentioned previously). I'll try contacting the jogg team about this.

WAV fix in. We use the javax package like I said but read it into a ByteBuffer so that might be where things go wrong. I implemented the ShortBuffer fix described in the thread you pointed to… Do me a favor and please pull from cvs and try your 16 bit wav files on the mac. I can’t easily test the fix at the moment. :confused:

Ok, we’ve got some interesting stuff here. First, I just noticed this error:

DigiCoreAudioDriver> Found 9 entries in 'SupportedApps.txt'.
## Component Manager: attempting to find symbols in a component alias of type (regR/carP/x!bt)
Mar 12, 2005 10:18:44 PM com.jme.sound.lwjgl.SoundSystem initializeOpenAL
INFO: OpenAL initalized!
Mar 12, 2005 10:18:44 PM com.jme.sound.lwjgl.SoundSystem initalizeEAX
INFO: Initalizing EAX
Mar 12, 2005 10:18:44 PM com.jme.sound.lwjgl.SoundSystem initalizeEAX
WARNING: Failed to Initialize EAX
org.lwjgl.LWJGLException: EAX instance could not be created.
        at org.lwjgl.openal.eax.EAX.create(EAX.java:64)
        at com.jme.sound.lwjgl.SoundSystem.initalizeEAX(Unknown Source)
        at com.jme.sound.lwjgl.SoundSystem.<init>(Unknown Source)
        at com.jme.sound.SoundAPIController.getSoundSystem(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.setupSound(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.simpleInitGame(Unknown Source)
        at com.jme.app.SimpleGame.initGame(Unknown Source)
        at com.jme.app.BaseGame.start(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.main(Unknown Source)
Mar 12, 2005 10:18:44 PM com.jme.sound.scene.SoundNode <init>
INFO: Node created.


However, HelloIntersection ran fine (I think the above error has to do with the fact that I'm using LWJGL 0.95). I can hear the static noise of the laser as before, but the noise of the explosion is slightly different. Before, it had been a very short sound, that lasted about a fourth of a second. Now, it is still just as short, but it sounds a bit different. I think it's only playing the first second of the explosion.wav for some reason. Based on the slight change in sound, I think you fixed it, but both times it's not playing the full file, and it's hard to make a decision based on half a second of sound ;)

The error you posted is simply a warning that EAX could not be instantiated… no worries there.



I’ll have a deeper look at this problem using my mac later this weekend and crack it! Thanks for your patience. :slight_smile:

Thanks! Very helpful! :smiley:

Any luck with the wav fix (to make it play the entire file)? Btw, I went to jobis’s site and downloaded the latest version of the library. It came with an application called JOrbisPlayer that was able to play many high quality ogg files (take a look at its play_stream() method). However, even after installing the latest libraries, I could only hear static as usual when firing a bullet in HelloIntersection. So does this mean that the problem with playing ogg files might actually be in jME?

Nothing yet, I am having trouble replicating your issue. :confused:

Does that mean you hear the full explosion on an OS X machine? (maybe it’s a problem on my side?)

explosion.wav plays ok on my mac, just if you are too far away from the target, it is very faint except for the initial part of the sound. Try having both the shot and the explosion sounds set to explosion.wav. You should hear the explosion much better. You can also hear the explosion by backing up, shooting and following the bullet quickly to the target.



The ogg file laser.ogg still sounds like garbage on my mac.



Hmm, using the same trick, I’m able to fix that too though. I can’t check the bitrate of the sound sample, so while laser.ogg now sounds good, it’s possible this fix doesn’t jive on the mac with other sound sources. Just needs some testing.



In CVS.

I get this error:

Mar 28, 2005 9:19:01 PM com.jme.sound.scene.SoundNode <init>
INFO: Node created.
Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO: Title=laser
Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO: Encoded by=MP3 To Wave Converter PLUS 2.341
Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO:
Bitstream is 1 channel, 32000Hz
Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO: Encoded by: Xiph.Org libVorbis I 20030909

Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO: Sample rate= 32000
Mar 28, 2005 9:19:01 PM com.jme.sound.lwjgl.SoundSystem loadOGG
INFO: Estimated Play Time 0.562
java.lang.NullPointerException
        at com.jme.sound.SoundPool.getBuffer(Unknown Source)
        at com.jme.sound.SoundPool.compile(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.setupSound(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.simpleInitGame(Unknown Source)
        at com.jme.app.SimpleGame.initGame(Unknown Source)
        at com.jme.app.BaseGame.start(Unknown Source)
        at jmetest.TutorialGuide.HelloIntersection.main(Unknown Source)
Mar 28, 2005 9:19:01 PM com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.


BTW, while looking through the code of SoundSystem.java and JOrbisPlayer.java, I noticed that they were very similar (even the same error messages). It seems like whoever wrote SoundSystem.java (Arman Ozcelik?) probably used this class as a guide. The thing is, is that JOrbisPlayer.java plays oggs fine on my computer, but SoundSystem.java obviously does not. :? I'll have to look into it more, but now that Sping Break's over, I'm gonna have much less time...

The NPE you are getting is because it can’t find a file. Maybe because I changed it to use explosion.wav. Have a look and make sure all of the files are present. Also double check the URLs after they are constructed for null.

Actually, it was because it was looking for explosion.ogg (changed it to explosion.wav). I’m still getting the same results as before though; the laser.ogg sounds like static, and no matter how much i turn up the volume, i can only hear a little blip from the explosion. :’(

Sounds like you aren’t getting the latest cvs then. Otherwise it would already be explosion.wav. Can you double check that? Pay attention to it potentially refusing to update do to cvs conflicts with changes you have made locally.

Ok, I was having some definite funkiness with my cvs dir so I deleted it and checked out a fresh copy. Now the laser works! :slight_smile: But I’m still getting just a blip from the explosion.wav. (although this is fine, because I’m never going to wrap wavs in any of my projects because of their size; it’s still odd why it does this).

no idea then. I even turned up the volume on it in the code to try and help there. :confused: Runs dandy on my mac and pc.

If I ever figure it out I’ll be sure to post back, thanks again for being so helpful! 8)