Some problems with Midi playback in Applets

I am currently writing an applet where you can train your ears to hear intervals, chords etc.

Link to the applet: http://www.springworldgames.com/eartraining/

I tried to use MidiSystem.getSynthesizer() and it worked great on my system but not on many others’. No sound was played at all.
Then I read about this issue and the fix was to use getSequencer() instead and only add midi events with Sequence and Tracks. Bizarre…

Well, I have implemented that now and it would be very nice to see if it works on your systems :slight_smile:

BTW, do you know if there are any issues with playing sampled sound in Applets using SourceDataLines? If there are no such issues, I plan to use Gervill with a bundled soundfont instead of relying on the Sequencer to work.

Your applet does not play sound on my 64-bit Ubuntu system running 64-bit Sun Java plug-in for Firefox. However, that is due to a known bug with 64-bit Sun Java for Linux, not your applet (I would have been surprised if it did work).

As for using SourceDataLine’s instead, there are some issues with Linux systems to consider. Specifically you will not be able to use the default Mixer whenever a USB webcam with internal microphone is attached, and Linux systems using the 64-bit Sun Java plug-in for Firefox will have problems with the gain and may not play any audio. (On the other hand, MIDI doesn’t work in 64-bit Sun Java anyway, so…). I wrote some pretty good “intelligent” Mixer-selection code for my SoundSystem, which you might find useful if you decide to go the SourceDataLine + Gervill route. Feel free to copy and paste anything you need. It will find an alternate Mixer to use in the webcam case. I haven’t solved the gain problem yet, though. I’ll be sure to let you know if I do.

Thanks paulscode!

I will use your Mixer-selection code. Thanks for sharing!

Now I have changed to a SourceDataLine solution with Gervill. I bundle a soundbank which is the reason for the sudden size explosion.

Works on my system now.