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

Offline Smith61

  • bit
  • Posts: 8
    • View Profile
Re: 3D Sound System
« Reply #90 on: July 17, 2013, 10:20:16 PM »
Okay so I tried placing the setAttenuation after creating, after the first block is passed in, after waiting to verify that the source is playing, and after moving the listener to the new position and neither worked. It played exactly like it had before. There is still also the problem with not being able to move raw stream sources from the origin.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #91 on: July 17, 2013, 10:31:14 PM »
That is not a separate problem -- exactly the same cause (feeding the data merely plays the source, it doesn't update the AL information on the channel to reflect the values for the source).  Like I said, there is a race condition here, so I'll have to come up with a permanent fix rather than the workaround.
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 ashrzr

  • bit
  • Posts: 3
    • View Profile
Re: 3D Sound System
« Reply #92 on: January 02, 2014, 02:26:12 PM »
Hey Paul. I use the SoundSystem to load all sounds for my game ahead of time with the player. Then, when I want to play a sound, I call quick play on the string that the player identifies. The sound plays no problem, but when I profile the game I notice that the SoundSystem creates almost 50 live threads (I have isolated it as the problem) when I play a sound. Why on earth is that?

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #93 on: January 02, 2014, 02:51:17 PM »
SoundSystem should have only two threads at most (one if you don't do streaming), in addition to the threads you are calling functions from (outside of the SoundSystem).  Could you post a simple test-case that demonstrates this problem?
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 ashrzr

  • bit
  • Posts: 3
    • View Profile
Re: 3D Sound System
« Reply #94 on: January 03, 2014, 08:08:14 PM »
This test creates a new thread for every sound (and doesn't ever dispose each thread):

Code: newbielink:javascript:void(0); [nonactive]
class GameSound
{

  static SoundSystem PLAYER;
 
  static void setup()
  {
    try {
      SoundSystemConfig.addLibrary(LibraryJavaSound.class);
      SoundSystemConfig.setCodec("wav", CodecWav.class);
    } catch (SoundSystemException E) {
      E.printStackTrace();
    }
   
    PLAYER = new SoundSystem();
    PLAYER.loadSound(GameSound.class.getResource("select_mechwhat1.wav"), "select_mechwhat1.wav");
  }


  public static void main(String[] args)
  {
    setup();

    for (int i = 1; i <= 20; i++) {
      PLAYER.quickPlay(false, "select_mechwhat1.wav", false, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, SoundSystemConfig.getDefaultRolloff());
      try {
        Thread.sleep(1000);
      } catch (Exception E) {}
    }
  }
 
}



I'm must be doing it wrong. Thanks.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #95 on: January 03, 2014, 10:13:39 PM »
You can look at the source code to confirm this, but if more than two threads are created, they are not being created from within the SoundSystem library itself.  Perhaps this is another issue with JavaSound.. have you compared to what you get if you use one of the OpenAL library plugins?

EDIT: After a little Googling, it looks like in fact this is a behaviour of JavaSound (each clip is given its own thread).  See here and here for example.  SoundSystem allows at most 32 simultaneous clips (which are the backend of each "normal channel" in the JavaSound library plugin), so you should not see more than that unless there is a bug.  Probably not much I can do to reduce this thread creation from the library, since this is how JavaSound is written to behave.  You could reduce the number of channels using SoundSystemConfig.setNumberNormalChannels() if 32 is too many for whatever reason.
« Last Edit: January 03, 2014, 10:28:02 PM 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 ashrzr

  • bit
  • Posts: 3
    • View Profile
Re: 3D Sound System
« Reply #96 on: January 04, 2014, 12:14:35 PM »
That's it! Thanks!

Offline wessles

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #97 on: January 25, 2014, 08:46:16 PM »
Great engine paul!

One issue I have, however, is how to load sounds via InputStreams. I am trying to load a sound from within the jar using Class.getClassLoader().getResourceAsStream(). I can only find a URL to feed into newSource(). Is there another way to create sounds than newSource() that accepts InputStreams?

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #98 on: January 26, 2014, 09:13:44 AM »
Why not use getResource() instead of getResourceAsStream()?  The former should return a URL instance.

Note that SoundSytem was original designed to load files from inside the JAR (the URL thing was added as a feature request later on).  Every command that takes identifier + URL parameters has a version which simply takes a filename.  By default, SoundSystem looks for the file in a package named "Sounds", but you can change it via SoundSystemConfig.setSoundFilesPackage().  If the files are under subfolders under a common root folder, call setSoundFilesPackage for the root folder, and then append the subfolder to the front of the filename when calling a method like loadSound.  If there is no common root folder for the sounds, you should be able to pass an empty string to setSoundFilesPackage (haven't actually tried this latter option, but it should work)
« Last Edit: January 26, 2014, 09:15:43 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 jpvguerreiro

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #99 on: January 31, 2014, 08:24:44 AM »
Hi Paul. I have been trying the 3D Sound System and it's really great. I have a question regarding the libraries used. The sound quality difference between Javasound and ljwgl is evident, however does ljwgl use HRTF to enhance the 3D audio?
I have read that LJWGL uses OpenAL soft, which has some HTRF support, but I'm not sure that it is using it and if I can do something to enable it. Do you have some information about that?

Thanks in advance!

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #100 on: January 31, 2014, 09:45:09 AM »
I've never tried modifying LWJGL myself, but a quick google search brought up a lot of information that should be helpful.  For example, I saw this on the Mincraft forums (Minecraft uses the SoundSystem library, so the info should be relevant).
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 Steveice10

  • bit
  • Posts: 2
    • View Profile
Re: 3D Sound System
« Reply #101 on: May 01, 2014, 08:46:32 PM »
If I may ask, what ever happened to the planned Android support for this? ( newbielink:http://www.jpct.net/forum2/index.php/topic,1057.msg16288.html?PHPSESSID=25bd63095174df2a15ae8956db80fecf#msg16288 [nonactive])

It would be a useful thing to have for cross-platform mobile/PC games.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System
« Reply #102 on: September 04, 2014, 03:15:13 PM »
Change in priorities.. SoundSystem took a back burner when things started taking off with Mupen64Plus AE.  I may eventually get back around to this one.
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 Brian_Entei

  • bit
  • Posts: 1
    • View Profile
Re: 3D Sound System
« Reply #103 on: October 20, 2014, 01:32:55 PM »
Hey Paul, love the sound system! I have been developing a game and I am using your sound system. It has been working great so far, but I can't seem to find a library for *.m4a files. So far I have *.mp3 *.ogg and *.wav files working. Is there a library out there that I can use to play the *.m4a files? And if not, how might I make a library for a specific file type? Thanks for the awesome sound system, keep it up! :)

Offline Javis

  • bit
  • Posts: 4
    • View Profile
Re: 3D Sound System
« Reply #104 on: January 04, 2015, 06:26:36 AM »
HI
Iv got a problem with the queuesound function.
I simply dont know how to use it  ;D
Can anybody help me ?