SoundSystem Beta ReleaseJAR:http://www.paulscode.com/libs/SoundSystem/16AUG2008/SoundSystem.jarSource Code:http://www.paulscode.com/source/SoundSystem/16AUG2008/SoundSystemSource.zipLet's see, there have been quite a few changes since the first release, so I'll try to list everything here.
1) Sample rate (playback speed) for stereo .oggs is now working for most .ogg files. I have found one stereo .ogg file that still plays too slowly, and I have also found some monotone .oggs that do not play at all (most monotone oggs are working fine, though). Strangely, one of the .ogg files that is not working is the "gunshot" sound effect I used in one of my previous demo applets. Since the file used to load and play properly, this seems to indicate that I may have broken something in the .ogg loading code. The good thing about that is I still have the source code for that demo applet. I should be able to compare line-by-line with the SoundSystem source code to locate the problem. This is an issue I will continue to work on, but for now it is acceptible. 95% of .ogg files play correctly for both OpenAL and Javasound (and I haven't found any sound files that "work for one but not the other").
2) There are new methods for creating fast sources: quickStream(), which I mentioned in my last post, and backgroundMusic(). backgroundMusic() creates a permanant, priority, streaming, looping, non-attenuating source and plays it. You can specify a source name or not, and you can also specify looping or not. The easiest way to use it is just
backgroundMusic( "music.ogg" );.
3) I fixed a number of null pointer exceptions caused when shutting things down or switching between libraries. I will continue to correct problems like these as they pop up, but for now I believe I got most of them.
4) There is a new SoundSystemLogger class for handling messages, as I mentioned in my last post. There are still "println's" floating around that I am working on removing. The next release will have the logger fully implemented in all classes.
5) I fixed a mirror-image bug with Javasound panning (sources to the right were playing in the left speaker and vice versa). Works correctly now.
6) I did some tweaking on the Javasound Rolloff attenuation, and I got it really close to OpenAL's rolloff attenuation. It's a far cry better than it was before. In fact, all the 3D effects I am emulating in JavaSound are pretty much dead-on matches to the built-in OpenAL effects (listener orientation, 3D panning, attenuation). On my PC I'd have trouble telling which library is active if I didn't write the code myself. In fact 3D panning is better in JavaSound, because it works for both stereo and monotone sounds ( ok, enough bragging
)
7) I made a major change to the way all sound files are loaded. Before, there used to be four slightly different ways of loading sound files due to the fact that there are two supported formats and two libraries. Now there is a file loader class which provides generic methods for reading from sound files regardless of their format. It handles the format-specific details in the background. This one class has been fully implemented for all file loading: wav or ogg, streaming or nonstreaming, OpenAL or Javasound. One good thing about this is now sounds will play at the same sample rate for both OpenAL and Javasound, so even if I don't ever fix the sample rate bug, a user could potentially just change the speed of his sound file to compensate for the bug. The best thing about this new loader, though, is that it can stream both wavs and oggs (before you could only stream oggs).
I spent most of today trying to get pause to work. I didn't think I was even going to get a release posted today because I had things torn apart. I am still nowhere close to getting pause to work. It is deceptively tricky. At the moment I have sources so they pause, but when they start back up, some of the queued sound data is getting lost. For non-looping sources it sounds like the sound gets cut off soon after resuming after a pause. For looping sources, it sounds like they are getting rewinded (thats in Javasound, non-streaming sources. I haven't got around to looking at the other situations just yet). I will work on this some more, but I am kind of beginning to wonder if this function is all that vital. Pause is good if you are making an audio player, but for video games, I am not sure where you would need to pause a sound (stop and play should be sufficient for most games). Does anybody else have some feedback on this issue? I just still haven't decided if a pause function is really worth all the effort.
--UPDATE--
I believe I figured out why I am having a problem with pausing. I think it is related to the SourceDataLine.stop() method being called from the command thread while data is being fed into the line from the stream thread. The stop() method ends both input and output, so maybe I just need to make sure input has completed before calling stop(). I could have the command thread set a boolean to pause the source, then the stream thread can actually call stop() when it is finished inputing bytes. I'll try this out and let you know how it goes.