Author Topic: 3D Sound System  (Read 185575 times)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #435 on: February 07, 2012, 10:27:58 pm »
Code: [Select]
java.lang.NullPointerException
at paulscode.sound.SoundSystemJPCT.tick(SoundSystemJPCT.java:270)
at graphic.Graphic3DController.update(Graphic3DController.java:708)
Aha, I can see that if it is hitting the exception at the beginning of the loop, then the subsequent source positions wouldn't get updated.  This most likely is the cause for your sounds not panning.  I'll see if I can verify that this is what's happening, and fix the problem if it is.  I'm not sure why the null pointer exception is happening in the first place, though.  This used to happen when using quickPlay, because I wasn't making sure when a temporary source is destroyed, that it gets removed from any objects it is bound to.  I thought I had fixed this problem, but I'll take another look at the code to see if I missed something.  Could be a thread synchronization problem.


And at the beginning there is this exception:
Code: [Select]
Initializing LWJGL OpenAL
    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
Error in class 'LibraryLWJGLOpenAL'
    Unable to initialize OpenAL.  Probable cause: OpenAL not supported.
    ERROR MESSAGE:
        Could not locate OpenAL library.
    STACK TRACE:
        org.lwjgl.openal.AL.create(AL.java:151)
        org.lwjgl.openal.AL.create(AL.java:102)
        org.lwjgl.openal.AL.create(AL.java:201)
        paulscode.sound.libraries.LibraryLWJGLOpenAL.init(LibraryLWJGLOpenAL.java:164)
        paulscode.sound.SoundSystem.CommandNewLibrary(SoundSystem.java:1576)
        paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2572)
        paulscode.sound.CommandThread.run(CommandThread.java:121)
    ERROR MESSAGE:
        Could not locate OpenAL library.

Starting up SoundSystemJPCT...
Switching to Java Sound
    (The Java Sound API.  For more information, see http://java.sun.com/products/java-media/sound/)
JavaSound initialized.

Do you get that same exception with the applet?  Make sure the OpenAL native library is on your system somewhere.


I am initializing this way:
Code: [Select]
public void initSoundSystem() {
        try
        {
            // add some plug-ins:
            SoundSystemConfig.addLibrary( LibraryLWJGLOpenAL.class );
            SoundSystemConfig.addLibrary( LibraryJavaSound.class );
            SoundSystemConfig.setCodec( "wav", CodecWav.class );
        }
        catch( SoundSystemException e )
        {}
soundSystem=new SoundSystemJPCT();
SoundSystemConfig.setSoundFilesPackage("");
}
With SoundSystemJPCT you do not need the calls to addLibrary and setCodec (these are done automatically in the background when you instantiate the SoundSystemJPCT object -- those calls are only a requirement for the core SoundSystem library).  That being said, even though calling these again is redundant, it shouldn't have any negative effects.

Since your problem is happening in JavaSound, I re-uploaded that test applet using JavaSound instead of OpenAL, just to make sure the problem isn't there.  The above link is the same.

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #436 on: February 07, 2012, 10:40:41 pm »
Oh I only downloaded the OpenAl jar, that you provided.
What OpenAl file(s) should I take? I want other users (which run my code) automatically download this file.

I just tested the new applet you uploaded.
Mhhh.. the sound is panned in the middle, no 3D effect.
www.forgottenelements.com
Free Action JAVA MMORPG

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #437 on: February 08, 2012, 12:36:01 am »
Oh, ok.  It is a problem with JavaSound then.  Oracle has royally screwed up JavaSound in recent versions by their decision to remove the "Java Sound Audio Engine" software mixer (requiring developers to choose one of the hardware mixers, which are all different with different capabilities for different sound cards).  I'm in the process of writing my own software mixer, but it will probably be some time before it is complete (I don't have much free time for programming any more, and what little I do have I am busy working on my N64 emulator project).  In the mean time, I would suggest using OpenAL, as it is more reliable (used to be JavaSound was more reliable, but not any more).

For the native OpenAL library, it ships with LWJGL (which I assume your application is using since you are writing it for jPCT, unless you are going with the software renderer)  It is included with all the other native libraries.

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #438 on: February 08, 2012, 01:35:45 am »
Thanks for your tipps and your help!

I am planning to release a first 3D Test Version for my game Forgotten Elements very soon (probably this week).
Yes, you're right, I am using JPCT and the hardware renderer.
So you suggest to use SoundSystemJPCT and provide the OpenAl version for the players, who download the game?
www.forgottenelements.com
Free Action JAVA MMORPG

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #439 on: February 08, 2012, 07:19:59 pm »
With the integrated OpenAl32.dll it works!
Unfortunately sometimes the Nullpointer Exception I mentioned before still occurs.
But I catch it and its ok.
Thanks again!
Marlon

Edit:
Everytime I exit my program (running at eclipse) the program crashes and I get the following error code:
Code: [Select]
Problemsignatur:
  Problemereignisname: BEX
  Anwendungsname: javaw.exe
  Anwendungsversion: 7.0.10.8
  Anwendungszeitstempel: 4e897db7
  Fehlermodulname: OpenAL32.dll_unloaded
  Fehlermodulversion: 0.0.0.0
  Fehlermodulzeitstempel: 4e894548
  Ausnahmeoffset: 0945d03f

Any ideas?
« Last Edit: February 09, 2012, 12:37:27 am by Marlon »
www.forgottenelements.com
Free Action JAVA MMORPG

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #440 on: February 09, 2012, 05:08:52 am »
I haven't seen that error before.  Do you know if cleanup is able to successfully finish before that error appears? (it should print a short blurb into the console stating I am the author once cleanup is complete)

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #441 on: February 09, 2012, 01:23:24 pm »
I haven't seen that error before.  Do you know if cleanup is able to successfully finish before that error appears? (it should print a short blurb into the console stating I am the author once cleanup is complete)

Yes, your name is written and it should clean up successfully.
By the way... is it possible to deactivate any console output?
www.forgottenelements.com
Free Action JAVA MMORPG

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #442 on: February 10, 2012, 11:33:55 am »
Yes, your name is written and it should clean up successfully.
By the way... is it possible to deactivate any console output?
You can deactivate the console output by creating a minimal extension of the Logger class with all the printing methods overridden (take a look at the sourcecode to see which methods).  If cleanup is completed successfully, I'm not sure what would be causing that crash.  You aren't trying to play any other sounds (like in the menus or on exit)?

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #443 on: February 10, 2012, 01:35:49 pm »
Yes, your name is written and it should clean up successfully.
By the way... is it possible to deactivate any console output?
You can deactivate the console output by creating a minimal extension of the Logger class with all the printing methods overridden (take a look at the sourcecode to see which methods).  If cleanup is completed successfully, I'm not sure what would be causing that crash.  You aren't trying to play any other sounds (like in the menus or on exit)?

I play sounds from the menu, but then I call quickPlay() without an Object3D.
I play an mp3 as stream as well, but I don't think that this causes the problem.
Is it possible to play mp3s as background music via your SoundSystem as well?
www.forgottenelements.com
Free Action JAVA MMORPG

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #444 on: February 10, 2012, 10:31:28 pm »
I play sounds from the menu, but then I call quickPlay() without an Object3D.
You should be fine as long as sounds aren't queued to play after the call to cleanup.  I'm not sure what would be causing that crash.  I can't seem to replicate it on my computer.

Is it possible to play mp3s as background music via your SoundSystem as well?
There is no mp3 codec plugin at the moment (must use the .ogg format instead)

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #445 on: February 14, 2012, 12:41:38 pm »
On my other computer SoundSystemJPCT seems to run fine (which is having other problems though).
There seem to be big differences between a Win 7 System and a Win XP System. :/
www.forgottenelements.com
Free Action JAVA MMORPG

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #446 on: February 17, 2012, 02:01:30 pm »
Hello, its me again.
I decided to use SoundSystemJPCT in the testing phase of my project.
However, there are some problems left:
1. As I mentioned before, on my Windows 7 Notebook the whole program crashes, when using the SoundSystem.
It crashes when I call SoundSystem.cleanUp(), when trying to close the program.
While running the program, there is no problem.
There is no error log, only a "JAVA(TM) Platform SE binary" window, after returning to windows.
It says:
Code: [Select]
Problemereignisname: BEX
  Anwendungsname: javaw.exe
  Anwendungsversion: 7.0.10.8
  Anwendungszeitstempel: 4e897db7
  Fehlermodulname: OpenAL32.dll_unloaded
  Fehlermodulversion: 0.0.0.0
  Fehlermodulzeitstempel: 4e894548
  Ausnahmeoffset: 0695d03f
  Ausnahmecode: c0000005
  Ausnahmedaten: 00000008
  Betriebsystemversion: 6.1.7600.2.0.0.768.3
  Gebietsschema-ID: 1031
  Zusatzinformation 1: 0a9e
  Zusatzinformation 2: 0a9e372d3b4ad19135b953a78882e789
  Zusatzinformation 3: 0a9e
  Zusatzinformation 4: 0a9e372d3b4ad19135b953a78882e789
On my other pc it runs without problems.

2. I want to play an ogg file as backgroundmusic. How can I load the ogg file (absolute path) from the disk and play it?
3. Is there a way to set a mastervolume for all sounds (played with quickplay()) and a mastervolume for the background music in a separate way?

Thanks for your help!
Marlon
www.forgottenelements.com
Free Action JAVA MMORPG

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: 3D Sound System
« Reply #447 on: February 19, 2012, 07:00:46 pm »
Forgotten Elements 3D Test Version was just released!
Feel free to check it out.
Tell me if the sound is running on your computer and the program exits without any problems.

http://www.forgottenelements.com
« Last Edit: July 12, 2012, 12:27:24 pm by Marlon »
www.forgottenelements.com
Free Action JAVA MMORPG