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

Offline Desmaster

  • bit
  • Posts: 2
    • View Profile
Re: 3D Sound System
« Reply #30 on: March 02, 2012, 03:54:16 PM »
That only reaches till paulscode.sound.codecs :o

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3472
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #31 on: March 02, 2012, 05:35:03 PM »
CodecJOrbis.java contains the CodecJOrbis class.  Either drop the source files into your project, or link with the pre-compiled JAR and add the line "import paulscode.sound.codec.CodeJOrbis" to the top of your source file that needs it.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline gouessej

  • byte
  • *
  • Posts: 17
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #32 on: June 11, 2012, 02:27:03 PM »
Hi

At first, don't worry about the sound sample that can only be played once with OpenJDK, it comes from its poor support of JavaSound, it is not a bug of your library. That one was the main reason forcing me to switch to JOAL 1.1.3.

However, I have a small problem. I use an in-memory sound, I get its source name, I can play it only if it is not yet already played. This is problematic because it is a gun shot, the second bullet should start making some noise before the first one ends doing so. I don't want to create several sources for a single sound sample. How can I make it work? The only workaround I know consists in shortening sound samples to avoid overlaps but it is annoying and crappy, it won't be fine when an opponent shoots me while I shoot him. Thank you for your good library. Best regards.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3472
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #33 on: June 11, 2012, 04:09:59 PM »
This sounds like a bug that I thought I had fixed, but maybe not.. do future calls to play() do nothing?  As I recall a workaround was to call stop() on the source before calling play(), so you might try that.  If it doesn't work, please send me one of the audio files that is having the problem (and let me know which codec you are using).  If you want to email me, my address is just paul at paulscode dot com (I didn't post the actual link, to avoid the spam bots).

That being said, the quickPlay() method is typically better for sound effects like gunshots, explosions, etc anyway.  With quickPlay you do not have to keep track of source names since they are handled internally by the library.  On the other hand, for longer-duration sounds, quickPlay is not always the best option if it is supposed to be attached to something that moves quickly, so it really all depends on the application.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline gouessej

  • byte
  • *
  • Posts: 17
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #34 on: June 12, 2012, 03:12:00 AM »
Hi

The future calls to play does something if I use another sound sample than the current one or once the current sound sample has ended being played. You can reproduce this bug by running the demo of the pre-beta version of TUER available here, just take the pistol (9mn) and the ammunition in the green box, reload with the right click and shoot with the left click:
http://tuer.sourceforge.net/very_experimental/tuer.jnlp
If you keep pressing the left mouse button, you shoot correctly but you hear the sound sample only half of the time. You can get the sound sample here:
http://tuer.svn.sourceforge.net/viewvc/tuer/pre_beta/sounds/pistol9mn_shot.ogg

I'm going to look at the source code of your library, I thought you simply prevented the same sourcename to be used several times at the same time.

Thank you for your help. I have to show my demo Tuesday, August, 7th, I hope it will just work fine.

Edit.: I should update the JARs of your library because I use those of 2010  :-X except for JOAL. I use JOrbis plugin, does the problem come from it?
« Last Edit: June 12, 2012, 03:20:51 AM by gouessej »

Offline gouessej

  • byte
  • *
  • Posts: 17
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #35 on: June 12, 2012, 03:40:26 AM »
Ok maybe I'm not using correctly the library because several bullets at different locations at the same time should use different source names. Is there a way of loading the sound sample once in memory and using it in several sources?

In Library.play(Source), you check that this source is not in use, that's what I thought. It is not wrong, this is not a bug, I misuse your library or an option should be added to allow skipping this test:
Code: [Select]
if( !source.playing() )
Edit.: I'm silly. Several sources can use the same identifier if they use the same sound sample from the same URL. Can I use loadSound once per file and then quickPlay with the identifier to play the same sound several times at different locations without loading them each time? I want to avoid useless I/O operations at runtime.
« Last Edit: June 12, 2012, 03:56:41 AM by gouessej »

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3472
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #36 on: June 12, 2012, 04:41:42 AM »
Several sources can use the same identifier if they use the same sound sample from the same URL. Can I use loadSound once per file and then quickPlay with the identifier to play the same sound several times at different locations without loading them each time? I want to avoid useless I/O operations at runtime.

Right, the library uses the identifier to identify whether a particular sample has been loaded yet or not.  Once a sample has been loaded and given a particular identifier, then that is the sample used any time that identifier is referenced-- it is not reloaded every time.  So for instance, say you were to try to load a second URL or file, but accidentally used the same identifier, the first one that was already loaded would be used, not the second one (people have actually reported this as a bug, but it is the intended behavior to prevent unnecessary I/O operations).


--EDIT--
But to answer your particular question, in order to play more than one instance of a sample simultaneously, you must have more than one source.  Otherwise, you would just be stopping the currently playing one and restarting it in a different location.  For sound effects like what you are using, quickPlay() is almost always the best choice, as I designed it specifically for this type of scenario (i.e. a video game with lots of rapid sound effects like gunshots and explosions).  And it doesn't reload the sound effects every time it is called either (the same sample/ identifier rules I mentioned still apply).  That's not to say that doing your own source pool and management schemes might not be better for some cases-- just pointing out that it is there in case you don't need to reinvent the wheel.
« Last Edit: June 12, 2012, 04:50:34 AM by Paul »
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline gouessej

  • byte
  • *
  • Posts: 17
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System
« Reply #37 on: June 12, 2012, 10:10:03 AM »
There is a spelling mistake in the documentation of quickPlay:
"The new sorce's name"
The "u" is missing.

People can still explicitly unload a sound if they want to load another one with the same identifier.

Thank you for your reply. When a bullet does not exist anymore in the game, its source should not go on existing, quickPlay is nice for this use case. Your explanation is fine, you're right about source pool and management and such things would be particularily useless in my case because I don't need to keep a given source after using it once, quickPlay doesn't keep it, this method just does what I need. Your source code is commented enough and quite clean, reading it really helped me to realize I was doing something wrong.

Offline scoude

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #38 on: September 25, 2012, 04:32:35 AM »
Hello Paul,

Just this message to indicate you that I joined a few days your environment SoundSystem in our software suite 'TbiSuite' and thank you for all the hard work!
In fact, I used another environment previously not working quite correctly and with your SoundSystem, it works perfectly!
For the moment, only TbiQuizzSonore software use your  environment. But with the next versions of other software, it will be extended!
TbiSuite is a suite of free and open software for school (children aged 2 ~ 8 years) using the interactive whiteboard we create me and my wife. I am a computer engineer and my wife is teacher with toddlers children!
If you're interested, here's the address of our suite:

newbielink:http://caroline-et-serge.coude.net/tbisuite/ [nonactive]

But it's only in french, sorry  ::)

Thank you again for your work!

Serge

Offline musikele

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #39 on: October 10, 2012, 04:32:13 PM »
Hello,
Sorry If I don't read all the thread but I have no time unfortunately :( so maybe my question has already been answered.
I'm searching for a java audio project that can be used in java and has this features:
- play multiple files at the same time (stereo or mono)
- use panning (for example, 75% on the right channel, 25% on the left)
- loop files or part of files (for example, if I have 10 clips loaded and playing altogether, and set start and stop loop points, it should loop only that part)
- most important of all ... do time shifting (slow down the music that is playing - even the group of files).
All this parameters might be changed at runtime.
Does your library do this?
It's ok for me to sponsor this project if it will support these features.
Please answer me by email because I don't know if tomorrow I'll find you again.

Cheers!

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3472
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #40 on: October 10, 2012, 05:04:41 PM »
Please answer me by email because I don't know if tomorrow I'll find you again.

I'm not too hard to find (top hit for the Google search "java 3d sound", and fifth hit for "java sound system").  That said, I sent you an email just to be sure  ;)

Here's what I sent, for anyone else with a similar question:

Quote
I do not think my library will fit your needs, unfortunately.  It does not have direct methods for looping parts of an audio file, or for time shifting.  There are hooks into the underlying library plug-in, so in theory these could be used to do the required functions through OpenAL or JavaSound directly (or better yet modifying the existing code since it is open-source).  However, since it sounds like you need a quick solution, these are probably not the best options in your case.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline bgroenks96

  • bit
  • Posts: 7
    • View Profile
Re: 3D Sound System
« Reply #41 on: December 08, 2012, 10:31:35 PM »
I posted an issue under support about this.

The 3D sound mapping in LibraryJavaSound doesn't work on Linux Mint 13 OpenJDK 6.  I will try installing the standard JDK later and see if it works on that (then it would be a Linux Mint issue).

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3472
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #42 on: December 09, 2012, 08:15:22 AM »
Thanks, I suspect it is a limitation with the available mixers.  Updating to Oracle probably won't solve it because they decided to remove their default software mixer from the library.  I started writing my own software mixer some time ago, but have been too busy to finish it.  If you come across an open source project like that someone else has done, let me know and I'll look into writing a Library plug-in for it.Otherwise things will probably still be on hold for a while.  Sorry!
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline bgroenks96

  • bit
  • Posts: 7
    • View Profile
Re: 3D Sound System
« Reply #43 on: January 30, 2013, 08:09:34 PM »
Thanks, I suspect it is a limitation with the available mixers.  Updating to Oracle probably won't solve it because they decided to remove their default software mixer from the library.  I started writing my own software mixer some time ago, but have been too busy to finish it.  If you come across an open source project like that someone else has done, let me know and I'll look into writing a Library plug-in for it.Otherwise things will probably still be on hold for a while.  Sorry!

Using Oracle's Java distribution for Linux does actually fix the problem.  The sound mixer appears to function normally.

Interestingly, I've just now discovered that OpenJDK 7 works as well.  It appears this must have been a bug with OpenJDK 6.

Offline bgroenks96

  • bit
  • Posts: 7
    • View Profile
Re: 3D Sound System
« Reply #44 on: January 31, 2013, 04:19:08 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.