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

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #45 on: January 31, 2013, 11:04:58 PM »
Scratch that.  Eclipse wasn't actually running OpenJDK.  The JavaSound Mixer for OpenJDK 7 is broken too.  The SoundSystem only works on Sun VMs then.

Yes, that is because Sun/ Oracle used to (and may started again in version 7) including the "Java Sound Audio Engine" software mixer.  Without it, you are at the mercy of available hardware mixers (which tend to suck).  I'll get back to looking at this problem again soon.  Surely someone has written a good open-source software mixer.  I know there is an excellent one that is licensed by the GPL (not a good solution for many applications, but it could help a few folks).  I'd like to find one with a more liberal license.
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline techwiz24

  • bit
  • Posts: 8
    • View Profile
Re: 3D Sound System
« Reply #46 on: February 11, 2013, 01:14:45 AM »
Is there any way to detect when a Streaming Source has finished playing? I'm trying to figure out if my sources have finished so I can clean up after them. When I mark them as temporary, I get null-pointer exception when calling millisecondsPlayed(source), but playing(source) still returns true...

EDIT: It might be an issue with LibraryJavaSound, upon inspecting a bit, javax.sound.sampled.SourceDataLine.isActive() always returns true on my system.
« Last Edit: February 11, 2013, 01:25:20 AM by techwiz24 »

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #47 on: February 11, 2013, 01:24:27 AM »
If you have a class that implements IStreamListener, you can call SoundSystemConfig.addStreamListener( this );  Then when any stream finishes playing, endOfStream( sourceName, queueSize ) will be called, notifying you that the stream has ended.
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline techwiz24

  • bit
  • Posts: 8
    • View Profile
Re: 3D Sound System
« Reply #48 on: February 11, 2013, 12:04:07 PM »
Handy! That helps a ton, thanks!

Offline cgomezr

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #49 on: February 17, 2013, 09:21:57 AM »
I'd like to chime in for a couple of things.

First, to congratulate Paul for the great work done in this 3D Sound System. I checked it some days ago and it's really easy to use, powerful and well-documented. I think this was very needed in the Java world, I was using another audio library but it ceased to be maintained around 2006.

And second, to say that if at some point you implement that non-GPL Linux mixer at some point, I (and some other people I know) would be really, really grateful. I maintain a BSD-licensed system that people can use to create text adventures in a relatively easy way. But I have been getting bug reports for years about simultaneous sounds not working under Linux. Over the years, I have checked several audio libraries in search of the holy grail of simultaneous sounds with Java on Linux, but none solves this. In the light of your posts, I suppose this is because none of them implements a software mixer. Having a library that solved this without having to resort to native code or shipping specific versions of the software for each OS (which sets me back a lot) would be a real godsend. And judging by Google searches, not only for me and my users - there are lots of reports of "Java program X doesn't mix sounds under Linux distro Y".

As I said, thanks for the good work and keep it up!

Offline gouessej

  • byte
  • *
  • Posts: 16
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #50 on: March 01, 2013, 02:45:49 PM »
Hi Paul

The JOAL library plug-in requires an update as some constants and methods have been moved. Moreover, JOAL now supports OpenAL-Soft too.

You can find an example of which changes I had to do recently here and here.

Best regards

P.S: I can contribute if you want.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #51 on: March 01, 2013, 02:59:46 PM »
Thanks for the help!  I'll take care of this and post an update (shouldn't take too much since you did all the work!)  ;D
« Last Edit: March 01, 2013, 03:01:34 PM by Paul »
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline gouessej

  • byte
  • *
  • Posts: 16
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #52 on: March 07, 2013, 10:53:54 PM »
Actually, your plugin already works as is with the latest version as you don't use OpenAL extensions.

However, can you decrease the delay used in this plugin in case of failure please? I have to wait for 30 seconds when OpenAL can't be loaded which often occurs under Windows :(

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #53 on: March 07, 2013, 11:00:54 PM »
I'll take a look at it this weekend.  I can't remember where it is spending all the time.  As I recall, it attempts to create a context, and if it catches an exception then it reports to have failed.  Perhaps that is where all the time is being spent, not sure?
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline gouessej

  • byte
  • *
  • Posts: 16
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #54 on: March 08, 2013, 06:27:54 PM »
I think you're right. I would only use a try catch in which I would call Alut.init() without adding a timeout, I don't know if it is feasible in your case.

Edit.: Look at SoundSystem.java line 1487.
« Last Edit: March 08, 2013, 07:01:50 PM by gouessej »

Offline msiggy

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #55 on: March 11, 2013, 10:50:14 PM »
Hey Paul,

I have an .ogg file which is about 3k in size and 3 minutes in length. When I load this file with 'soundSystem.loadSound(filename)' It takes up a huge amount of memory ( 800mb) in my application. Whats weird is if I just play it with soundSystem.backgroundMusic() without loading it first, it takes up a normal amount of memory. This activity only seems to happen with certain .ogg files, some other ones I have work fine. It seems like there is something weird in the loadSound() method. Or perhaps my file has some funny attribute that isn't playing nice. Let me know if you want a copy of the .ogg file and I will send it to you. I cant put a link here because the sound is proprietary.

Thanks,
Mike

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #56 on: March 11, 2013, 11:13:46 PM »
That is way too large to pre-load.  Use a streaming source for it instead of a normal source (that's what backgroundMusic does behind the scenes). That way the entire decoded audio doesn't have to be loaded in memory at once.
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline gouessej

  • byte
  • *
  • Posts: 16
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #57 on: March 15, 2013, 12:27:58 PM »
Hi Paul

Sorry to disturb you once more. I have only found the line of code that displays the message: SoundSystem.java line 1487

I haven't found a way of decreasing or removing the annoying delay (30 seconds). Please can you help me? OpenAL works reliably on lots of Windows machines, I don't want to use Java Sound under Windows in all cases just because of this delay.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3185
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #58 on: March 15, 2013, 12:59:43 PM »
Sorry for the delay.. things have been really hectic between work and my main project.  I promise I'll look at the SoundSystem this weekend.
Device: Samsung Galaxy Nexus
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: 3.0.31-g396c4df (Android 4.2 Jelly Bean)

Device: Motorola Droid X
CPU: TI OMAP3630-1000, 1 GHz (single core, ARM Cortex-A8)
GPU: PowerVR SGX530, 200 MHz
RAM: 512 MB
Resolution: 480 x 854
Rom: Verizon 4.5.573.MB810 Gingerbread 2.3.34, rooted

Offline gouessej

  • byte
  • *
  • Posts: 16
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #59 on: March 15, 2013, 01:52:13 PM »
Don't be sorry, you already do your best. I'm going to investigate a bit more in order to give you some complementary indications so that you will spend less time in fixing that.