3D Sound Engine

– This slot is reserved for the most recent working releases –

This is a 3D sound system for Java which provides a common interface to various 3rd-party sound and codec libraries. It is free to use in any project, commercial or otherwise, and the sourcecode is included in the following links.

Downloads:

Sound System Version date: October 23, 2010
The core SoundSystem library, independent from 3rd-party libraries. It is stripped down to the bare essentials, and designed to be easily customizable with various sound library and codec plug-ins. If memory is a concern (such as in an applet) this may be a good option, because it allows you to choose as many or as few plug-ins as you require for your project. NOTE: The core SoundSystem library without any plug-ins is only capable of playing MIDI files. Additional plug-ins should be added for more capabilities. The source code and license are included in the .zip file.

Sound System jPCT Version date: October 23, 2010
The jPCT-friendly 3D sound library. The SoundSystemJPCT class overrides the core SoundSystem libray, and provides a number of methods to make adding 3D sound to any jPCT project easy. It includes methods for binding Listener to Camera and Sources to Object3Ds, as well as using SimpleVector parameters. SoundSystemJPCT utilizes the LWJGL binding of OpenAL (with JavaSound as a backup option), and the J-Ogg library for .ogg support. NOTE: The core SoundSystem library, source code, and all relevant licenses are included in the .zip file.

SoundSystem Utils Version date: August 9, 2009
Includes a SoundSystem loader, and an example XML file.

Plug-ins:

JavaSound library plug-in Version date: October 23, 2010
Interface to the Java Sound API. More compatable than OpenAL, but not as high quality and fewer features. This plug-in utilizes JavaSound’s panning and volume control methods to simulate an reasonable-quality 3D sound system. Known bug: quickPlaying sounds will begin playing them at full volume for a split second, before switching to the correct volume. This is a bug with the Java Sound API itself, and therefore beyond my control to correct. An easy workaround is to add 0.02 seconds of silence to the beginning of each sound effect (the free Audacity sound editor works well for this).

LWJGL OpenAL library plug-in Version date: August 24, 2010
Interface to the LWJGL binding of OpenAL. The LWJGL library (http://www.lwjgl.org) is required for this plug-in to work. This library sounds much better than Java Sound, but is not as compatable. I recommend using the JavaSound library plug-in as a backup option. NOTE: Please read the included LWJGL license.

JOAL library plug-in Version date: August 29, 2011
Interface to the JOAL binding of OpenAL. The JOAL library (http://jogamp.org) is required for this plug-in to work. As mentioned previously, this library sounds much better than Java Sound, but is not as compatable. I recommend using the JavaSound library plug-in as a backup option. NOTE: Please read the included JOAL license.

WAV codec plug-in Version date: October 23, 2010
Adds support for .wav files.

JOgg codec plug-in Version date: August 24, 2010
Adds support for .ogg files using the J-Ogg library. This codec is less compatible than the JOrbis codec, but the license is less restrictive. Sometimes running incompatable .ogg files through a converter will make them compatable. NOTE: Please read the included JOgg license.

JOrbis codec plug-in Version date: November 23, 2010
Adds support for .ogg files using the JOrbis library. More compatible than the JOgg codec, but reads data more slowly (it may not be possible to stream more than one file simultaneously when using this codec). This plug-in is licensed by the LGPL. NOTE: Please read the included LGPL document.

IBXM codec plug-in Version date: August 24, 2010
Adds support for Protracker, Fast Tracker 2, and Scream Tracker 3 (.s2m, .mod, and .xm) files using the IBXM library. File sizes for these formats tend to be quite small, so this may be a good option for background music. This plug-in is based on or using the IBXM library, which is bound by the BSD License. NOTE: Please read the included license document.

JSpeex codec plug-in Version date: August 24, 2010
Adds support for .ogg or .wav files encoded with Speex (a compression optimized for human voice). See http://www.speex.org/ for more information.

Documentation:

JavaDoc Version date: October 23, 2010
Also includes the JavaDocs for SoundSystemJPCT and all library and codec plug-ins, and the utils library.

3D Sound with SoundSystem PDF (download the example programs)
A tutorial-style guide to using the core SoundSystem library (last updated: April 14, 2009).

Guide to SoundSystemJPCT PDF (download the example programs)
Another tutorial-style guide to using SoundSystemJPCT. (last updated: April 14, 2009).

Demos:

Sound Effects Player (download the Source Code)
Demonstrates library switching on the fly, streaming background music, playing MIDI, and playing multiple sources simultaneously. Last updated 21 August, 2010

Bullet / Target Collision (download the Source Code)
Demonstrates the LibraryJavaSound plug-in. Last updated 30 March, 2009

Holy Bouncing Helicopter Balls! (download the Source Code)
Demonstrates moving through a world with multiple sources. Last updated 21 August, 2010

What’s new?

[i]- Fixed JOAL package name from the old net.java.games.joal to the new com.jogamp.openal

  • Updated CodecWav link to current version
  • Improved LibraryJavaSound performance slightly in non-Sun Java versions
  • Handled rare pan-control exception
  • Fixed fadeOutIn bug which caused fade-in effect to be silent
  • Fixed a bug where certain types of .ogg files created in versions of Audacity were cut off just before the end of the sample[/i]

Excellent! I’m trying out the jPCT Sound System library, I’ll let you know how it goes.

Great work :slight_smile:

Miscellaneous updates and bug fixes

The following elements have been updated:

Sound System jPCT
Sound System

JavaSound library pluggin
LWJGL OpenAL library pluggin
JOAL library pluggin

WAV codec pluggin
JOgg codec pluggin
JOrbis codec pluggin

JavaDoc
3D Sound with SoundSystem (example programs)
Guide to SoundSystemJPCT (example programs)

What’s new?

[i]- Finished writing the long-awaited tutorial guide for SoundSystemJPCT.

  • Corrected a thread synchronization problem that caused occasional NulPointerExceptions when temporary (quickPlay) sources were bound to Object3Ds.
  • Fixed a bug in the JavaSound library plug-in where ambient sources were 3D panning between left and right speaker rather than being ambient.
  • Fixed a problem in bindListener where the listener did not initially match the camera until tick() was called for the first time.
  • Eliminated a long pause that was being added to the end of streaming sources when using the Wav and J-Ogg codec plug-ins.
    [/i]

At the request of a couple of users, I added the ability to manipulate pitch. This is a useful feature, because making slight random pitch changes when playing sound effects can help reduce the repetitiveness and make a game’s sound effects more believable. Also, this could potentially be used to create a “Doppler effect” for moving sources.

There are two new methods in the SoundSystem class:

getPitch( String sourcename )
setPitch( String sourcename, float newPitch )

possible values for pitch are 0.5f - 2.0f (where 1.0f is normal pitch). Changing the pitch also changes the playback speed. I uploaded the updated SoundSystem core and library pluggins. The links in my initial post are still the same.

Since there are already several people using SoundSystem in their projects, I don’t want to break the existing quickPlay method by adding in a parameter for initial pitch if it isn’t necessary. The following can be used instead:

soundSystem.setPitch( soundSystem.quickPlay( ... ), initialPitch );

This works fine on my computer, but if there winds up being latency problems with this method on slower machines, I will go back and change the quickPlay method.

At the request of a user, I added a new ‘loadSound( String identifier, URL url )’ method and uploaded the updated library. This allows you to use a URL instance rather than specifying a String filename parameter. The links on my original post are still the same. Changes were applied to the SoundSystem core and all library plug-ins. The ‘String identifier’ parameter must end in the file’s extension (example “whatever.ogg”), so SoundSystem knows what codec to use when reading from the URL. This identifier can be used for the ‘String filename’ parameter in the newSource and quickPlay methods.

I have your “Sound System” running. Works great and real easy to use.

For my needs, I’ll just stay with Java Sound playing wav files. Sounds good to me and I don’t need anything too fancy.

Thanks for the hard work!

Today I finished a major update to the SoundSystem. I wrote a new class to make switching between String filename/identifier and URL on the fly very easy. I worked it into all the streaming methods and the MIDI channel stuff (as well as reworking the loadSound method to use this new setup), so now either URLs or filenames can be used with all types of sources (MIDI, normal, and streaming). Everything seems to be working after running several quick tests. However, since the change was rather extensive (I ended up editing almost every class), I need to spend some time doing more extreme testing to make sure the library is still stable and all features work. I also have a couple more small additions I want to add before the next release.

Sound System, Cumulative Updates/Bug-Fixes

Sound System
Sound System jPCT
Sound System Utils

JavaSound library pluggin
LWJGL OpenAL library pluggin
JOAL library pluggin

JOrbis codec pluggin

-Made it so initializing OpenAL plug-ins will notify when AL_PITCH is not supported
-Fixed vorbis-header compatability issue with OGG files generated by Audacity
-Improved error-handling in multiple classes
-Updated and added multiple classes to allow user to specify either String filenames or URL instances
-Added new class to associate filename/identifier with URL
-Improved MIDIChannel class - searches for alternate sequencer/synthesizer if defaults don’t work
-Added a new method for feeding raw audio data directly to a channel through streaming sources
-Added a new source-creation method to produce streams that can be fed directly with raw audio data
-Added a new SoundSystemUtils library which includes an XML loader
-Corrected problem in LibraryJavaSound plug-in where sources would only play once
-Corrected channel-source association bug which caused rare odd behaviors

Something I changed seems to have broken Command synchronization. I am currently looking into the problem, so please stand by.

Ok, I solved the problem. This logic error has actually been in the code for a very long time, but it never manafested itself until now. I had to change the CommanQueue/ManageSources infrastructure to correct it, so any legacy code that extends the SoundSystem class for customized source management models will most likely now be broken. If this causes problems for anyone, please refer to the JavaDoc for the proper new way to do custom source management, or post questions here for help. Sorry any inconvenience this causes.

Updated packages:
Sound System
Sound System jPCT
Sound System Utils

I fixed one more minor bug - a looping MIDI source without any sequences its play queue wasn’t looping. I went ahead and uploaded the fixed JAR and sourcecode (only the SoundSystem core was affected by the change).

Also, I finished my new and improved Helicopter Balls applet (taking the silliness to a whole new level):

Helicopter Balls Applet

And if you want the source code (not sure why anyone would):

Helicopter Balls Source

The new helicopter applet looks great… but you should know it has the infamous Mac bug (that you get from not setting up the applet “correctly”). :wink:

Never heard of that before. How does one set up an applet correctly?

Great engine! I retrofitted my game with it in under an hour.

Maybe I didn’t see it while scanning the documentation at turbo speed, but I couldn’t figure out where to place the sounds in my jar until I looked at how your helicopter demo was built.

Another plugin that would be nice would be one for the IBXM library (for .mod files).

It’s a library and player released under LGPL here and apparently under BSD license here.

Edit: I just noticed there’s a sunet2000 user on java-gaming.org, and they list their website as IBXM. Small world.

I thought I would look into that IBXM library, but I’m having a little trouble finding where to download the actual source code. The first site you listed has no downloads at all that I can see, and the second one you listed (which is linked to by the first one, BTW) only has a link to download the compiled JAR but no source code. I am little confused, not only by the fact that the project is listed under two different licenses, but also because both of those licenses are supposedly “Open Source” licenses, which should mean the source code is available to download from somewhere… If you happen to know where I can get my hands on the source, let me know. In the mean time, I’ll keep digging around to see if I can find it. I suppose I could write an IBXM plug-in that requires that external JAR, but I would prefer to drop the source into my JAR to make things a bit easier for the user.

The jar contains both source and class files. There may need to be some tweaking of the source (I think it tries to grab source data line thingies directly for playback), but if it’s available under BSD license I suppose that’s no big deal.

So it does. I’ll look into it, and keep you posted.

I finished writing a codec plug-in based on the IBXM library. I haven’t had time to test it very extensively yet, but the IBXM library is quite intuitive so I don’t forsee any problems. Let me know if something doesn’t work properly.

IBXM codec plug-in Version date: October 13, 2009
Adds support for Protracker, Fast Tracker 2, and Scream Tracker 3 (.s2m, .mod, and .xm) files using the IBXM library. File sizes for these formats tend to be quite small, so this may be a good option for background music. This plug-in is based on or using the IBXM library, which is bound by the BSD License. NOTE: Please read the included license document.

That’s some fast work ;D

The mod files sit nicely between ogg and midi in the quality/size spectrum. Perfect for keeping applet sizes down. Thanks heaps.