3D Sound Engine

The

Exception in thread “Thread-15” java.lang.InterruptedException: sleep interrupted
is thrown directly after starting the applet, before I can try to play a sound or midi.

[quote]But if it only happens in that one version…
[/quote]
the installer says I have the latest JRE, so maybe it is a problem.
No problem for me, I don’t use your engine yet. :wink:

[quote=“Hansdampf,post:41,topic:33341”]
I meant for the versions that don’t throw the exception - do both MIDI and sound work?

Stupid question, but where does one download HotSpot (vs. plain old Sun Java that everyone normally uses)? They aren’t the same thing, right?

[quote]They aren’t the same thing, right?
[/quote]
Hotspot is Java’s JIT. So they are the same thing.

Gotcha. Well then I can’t reproduce the problem here, since that is the same version I have installed on my test machines, and the applet runs fine for me in all of the following setups:

Windows XP 32-bit
Internet Explorer
Firefox

Windows Vista 32-bit
Internet Explorer
Firefox

Windows 7 64-bit
Internet Explorer 32-bit
Firefox 32-bit

Ubuntu 64-bit
Firefox 64-bit **(Unstable plug-in)
Firefox 32-bit

Then it can be a problem of win7 32 bit? (my OS). It is not in your list.
Hard to imagine for me.
Good luck!

Not at all. SoundSystem has been extensively tested on numerous systems running Windows 7 32-bit on both IE and Firefox. That list is just the setups that I am running here at home on my own test machines. My point was that I am unable to replicate the problem on my test machines for debugging since I’m using that same version of Java from multiple OS’s, browsers, and architectures.

Getting back to your problem, though, if I can’t get MIDI to work (which seems likely based on the output, indicating an inability to acquire a Sequencer), at the very least I should still be able to catch that exception to allow SoundSystem to continue running. It would just mean that in the rare cases where this problem happens, users would just not be able to play MIDI.

Before I give up, though, let me research to see if there is another way I can acquire a Sequencer, which might eliminate that problem. My first thought is to catch the Exception and then immediately try again, since that Thread in question should be awake now.

Ok, here is my first test. Could you please run this applet and copy the output? Also let me know if it plays anything.

http://www.paulscode.com/source/MIDI/MIDIApplet/

I tried a couple of different things in this applet If an InterruptedException is caught when trying to grab the default Sequencer, it tries again. If that doesn’t work, then it tries looking up one of the common Sequencers by name from the list of available MIDIDevices. Hopefully one of these things will work.

midi plays fine (1.6.0_18-b07)


Using 'Real Time Sequencer' as the Sequencer.
The sequencer is NOT an instance of Synthesizer
Using 'Java Sound Synthesizer' as the Synthesizer.
Method 'getDefaultSoundbank()' returned 'null'.

Awesome, I’ll incorporate the changes into the SoundSystem.

I added your sound library to my game www.chippeddagger.com. It works great! Nice work Paul!
cheers,
don

Awesome, nice work on the game! It runs beautifully for me on Ubuntu 64-bit, Sun Java 6 64-bit.

Let me know if any of your clients have a problem with the sound. The more people using the library, the more compatible I’ll be able to make it.

One known issue with the LibraryJavaSound plug-in is no sound for users who are running one of the many open-source JRE’s other than Sun Java (like OpenJDK which ships with Ubuntu 64-bit, for example). The cause of this is that the “Java Sound Mixer”, which LibraryJavaSound relies on, is only available in Sun Java (which most users have, but a few might not). If anyone has this problem, they can download Sun Java for free from the Sun/Oracle website http://java.com/en/download/index.jsp, and that will correct the problem. I’m currently working on an intelligent method for choosing an appropriate Mixer from whatever is available if “Java Sound Mixer” is not found. This should hopefully make it so the LibraryJavaSound plug-in will work with other JREs besides Sun Java only. I’ll post an update here if I can get this working properly.

I’ve been pleasantly surprised by the complete lack of any bugs. That or maybe players are confusing sound related bugs with all my regular bugs. :persecutioncomplex: I will certainly keep you up to date with any bugs we do come across, but so far it’s been smooth sailing!
cheers,
don

This looks great, exactly the kind of library I was looking for.

I’m going to be implementing this very soon into my own game. :slight_smile:

One more happy user of your engine :slight_smile:

Could you tell me how I can use your engine with my procedurally generated sounds?
I went through the tutorial and had a look at the source code but I didn’t get it working.

This is one of my tries:

SoundSystem ss=new SoundSystem();
ss.rawDataStream(audioformat, false, "gen", 0,0,0,0,0);
ss.feedRawAudioData("gen",data);

It would be nice if I could handle generated sounds like sounds loaded from a file. Is that possible?

[quote=“Hansdampf,post:56,topic:33341”]
That aught to work, unless there is a bug I need to fix. What happens when you run this code? Which library plug-in has the problem (or do they all)? If it is just not playing anything (no errors or exceptions), here are a couple of things you could try:

  1. Pass the stream an initial chunk of data or two before calling ss.play( “gen” )
  2. Try increasing the size of the data chunks

Let me know if either of these things help.

[quote=“Hansdampf,post:56,topic:33341”]
Good point - I probably should add the ability to create a “normal source” from generated audio data (rather than streaming being the only way to deal with generated data). This should be a pretty simple addition. Is that what you are talking about, or did you have something else in mind?

I used LibraryJavaSound.class and adding

ss.feedRawAudioData("gen", new byte[2]);

made it work.

Yes, exactly! That would be fantastic and I could ditch my own broken sound engine :smiley:

One user still happy of not having to write its own sound library ;D I looked at some other attempts to wrap Java Sound API and there are more buggy and/or less documented.

I’ve just started with your sound system and I must admit, it looks great. The only problem I’ve struck so far is that I cannot adjust the volume on any MIDI tunes. The volume controls work for WAV files, but not MIDI. I’m using the JOAL plugin