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

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #75 on: April 17, 2008, 01:59:31 pm »
What are you doing, when the user presses escape?

In the no-sound applet, I am doing nothing (just setting "loop = false" to end the game loop.  Is there some "shut down" stuff I need to do to jPCT?  That could be the problem.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 3D Sound using lwjgl binding of Open AL
« Reply #76 on: April 17, 2008, 02:53:43 pm »
Maybe removing the canvas from the applet helps...IIRC, we had some thread about this here, but i can't remember the outcome.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #77 on: April 17, 2008, 03:18:05 pm »
Maybe removing the canvas from the applet helps...IIRC, we had some thread about this here, but i can't remember the outcome.

Ok, good idea.  I added in the line
Code: [Select]
this.remove( myCanvas ); in the shutdown method, and I re-uploaded the Helicopter applet.  Hopefully that will fix the problem.  The link again:
LINK NO LONGER EXISTS

Oh, BTW, I finally managed to clean the virus off my main pc.  I ended up loosing a bunch of stuff after returning to a previous restore point.  Last scans with updated AVG, spybot, and adaware all came out clean, so hopefuly it is finally gone.  It was a nasty one that locked out my administrator privilages and created a new administrator account (I assume to let someone connect to my computer remotely).  I detected the virus immediatly and quickly disconnected the network cable, so I doubt they got much.  I hate hackers - got nothing better to do with their lives than mess with other people's.  >:(
« Last Edit: September 18, 2008, 01:01:14 am by paulscode »

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: 3D Sound using lwjgl binding of Open AL
« Reply #78 on: April 18, 2008, 11:06:42 pm »
Well, I suppose your probably sick of me giving bad news concerning this applet, but things are even stranger now.
When I press escape firefox's and IE's windows both close out. But if I simple close the tab of the applet in firefox, the other tab continues to run ok.  ::)

I was thinking maybe you should post this on the lwjgl forums to see if anyone else has this problem. Or maybe did you already do that?

Quote
Maybe removing the canvas from the applet helps...IIRC, we had some thread about this here, but i can't remember the outcome.
I think that was me, and no it never got resolved, but that was on a different pc. I just decided to tell the user to choose gl or software.

Jman
« Last Edit: April 20, 2008, 02:16:33 pm by JavaMan »

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #79 on: May 05, 2008, 11:36:49 pm »
Hey, just wanted to let anyone who is waiting for the next release of SoundManager know, I am taking a break from programming for a month and a half.

I managed to obtain a (hard to get) waiver allowing me to take my Air Force promotion test a year earlier than expected :D  I'll be testing the beginning of next month, so between now and then I will be spending all my free time studying.

After that, if all goes according to plan, I am taking two weeks of leave to visit family in Kansas and California, so I won't be doing any programming until I get back home to Maryland.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: 3D Sound using lwjgl binding of Open AL
« Reply #80 on: May 06, 2008, 03:41:16 am »
Good luck with that. 
click here->Fireside 7 Games<-

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: 3D Sound using lwjgl binding of Open AL
« Reply #81 on: May 06, 2008, 03:30:40 pm »
Have a nice time in California! The land of tech. ;D

Jman

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #82 on: May 10, 2008, 03:30:01 am »
Ok, I know I said I was going to spend all my free time studying.
But I have alway heard that it is good to take a break every now and then...

Ok, fine - I'm really just a programming junkie  ;D

Anyway, I have been looking more closely at Java Sound, and it looks like it is every bit as capable a library as OpenAL.  I am going to continue looking into the differences between them, but initially I am kind of wondering if it might be a good idea to just use Java Sound and forget about OpenAL.  I have posted the following question on other forums as well, and thought I would post it here too, in case any of you have input on the subject:

Is there any advantage to using OpenAL vs Java Sound (specifically performance or compatibility issues), and would there be a real benifit to having SoundManager capable of both?  Or would using only Java Sound make more sense, in order to reduce complexity?

I suppose I will know more when I create some test applets and compare performance.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 3D Sound using lwjgl binding of Open AL
« Reply #83 on: May 10, 2008, 10:38:07 am »
My experience from Paradroidz was, that Javasound was:

a) more compatible when using software mixing
b) less compatible (close to 0%) when using hardware mixing
c) slightly slower

than OpenAL.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #84 on: May 10, 2008, 11:11:53 am »
My experience from Paradroidz was, that Javasound was:

a) more compatible when using software mixing
b) less compatible (close to 0%) when using hardware mixing
c) slightly slower

than OpenAL.

Sounds like there would be a benifit to including both into my library, then.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #85 on: May 10, 2008, 04:41:33 pm »
I have started working on a new class today, called SoundSystem.  It is basically going to be an interface class that will handle all calls to both sound libraries, and allow switching between them.  In other words, the SoundManager and SourceManager classes will be able to call methods like SoundSystem.initialize(...), SoundSystem.play(...), etc, without directly accessing methods from either library.  This will not only make things more organized, but it will also make future expansions much easier.  It should also help in simplifying thread synchronization and tracking down thread conflicts, by keeping all the synchronized sound-related methods together in a single class rather than spread out in three classes as they are now.

SoundSystem will initially support only OpenAL, until I get it incorporated into my library and debugged.  I will then expand it to support Javasound.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: 3D Sound using lwjgl binding of Open AL
« Reply #86 on: May 11, 2008, 06:05:27 pm »
Sounds good.
click here->Fireside 7 Games<-

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #87 on: May 14, 2008, 11:16:10 pm »
Progress update

After doing some work on the SoundSystem class, I am starting to see how useful this interface is actually going to be.  So I've decided to make SoundSystem a library that can be used separately from SoundManager.  I think it could be useful for people who want to use both OpenAL and Javasound in their project, but they don't want the high-level components of SoundManager, such as source management.  With SoundSystem, you wouldn't have to learn the syntax for two seperate libraries, or worry about thread issues.

Therefore, I my plan now is to implement and debug the SoundSystem library before reworking SoundManager to use it (contradicting what I said in my last post).  I'll keep everyone updated, and I'll post the JAR and source for the library when I finish it.
« Last Edit: May 14, 2008, 11:39:45 pm by paulscode »

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: 3D Sound using lwjgl binding of Open AL
« Reply #88 on: May 15, 2008, 03:37:34 am »
I am trying to write a logrithmic attenuation algorithm for Javasound, since it doesn't have one built into it by default like OpenAL does.

My understanding of how attenuation works in the real world, is that waves attenuate according to the inverse of the distance squared:

Code: [Select]
intensity = initialIntensity / (1 + distance * distance);
So with sound waves, volume should be:

Code: [Select]
volume = initialVolume / (1 + distance * distance);
And then adding in a rollOff factor:

Code: [Select]
volume = initialVolume / (1 + rollOff * distance * distance);
Now here is were I am stumped.  From what I understand, the "logrithmic" part of a logrithmic attinuation algorithm is there to compensate for the fact that the "loudness" of a sound detected by the human ear is not a linear function of that sound's decible value.  I've been searching the internet, but I can't figure out exactly what I need to add to my formula for it to match what OpenAL does.

I thought I would post this here in case anyone happens to know anything about this topic.  If not, I will just use the formula as is.  Only drawback is my algorithm doesn't match the OpenAL algorithm, so you'd have to use different rolloff factors depending on whether you were in OpenAL or Javasound mode, and the attinuation effect would not be the same for both libraries (which may complicate things for the user).

Other solution would be to not use the built-in OpenAL logrithmic attenuation model, and use my algorithm for both Javasound and OpenAL.  This would reduce the realism achieved with OpenAL, but it would ensure that both libraries have the same behavior.
« Last Edit: May 15, 2008, 04:14:24 am by paulscode »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 3D Sound using lwjgl binding of Open AL
« Reply #89 on: May 18, 2008, 01:34:12 pm »
Personally, i could happily live with both solutions giving a little different results. I would leave OpenAL as it is and add your own solution to JavaSound until you can come up with the correct solution. Nobody will hear the difference anyway... ;)