tags:

views:

124

answers:

1

I managed to play midi files using Java, but it produces some distracting noise. I figured out that this is caused by the poor quality soundbank file shipped with Java 6 SDK/JRE.

How can I improve that quality?


Here is what I have so far:

  • MidiNote example using a Receiver works fine (sounds the same as when playing midi files with other players), so it does not seem to use the Soundbank shipped with Java but the fallback mechanism that uses a hardware MIDI port.

  • Using SimpleMidiPlayer example to play a Midi file works, but the quality is poor.

  • When I delete lib/audio/soundbank.gm, the quality is not bad any more, so the fallback is used again.

  • When I put soundbank-deluxe.gm into the same directory, it is used and produces much better sound.

Messing with the clients soundbank file as described in the official Installation Instructions certainly isn't an option, so I tried to put the new soundbank-file into the jar-file and load it:

Soundbank soundbank = MidiSystem.getSoundbank(
      getClass().getResourceAsStream("soundbank-deluxe.gm"));

if(synthesizer.isSoundbankSupported(soundbank)) {
    System.out.println(synthesizer.loadAllInstruments(soundbank));
}

This prints true, but the sound remains unchanged.


  • What am I doing wrong loading the soundbank file?
  • Can I force the hardware MIDI port to be used instead of the standard soundbank file?
A: 

Someone has to ask, and I'm suprised no one has yet. I assume you have checked that the sound file plays appropriately by other means, and that the 'noise' is not actually contained within the file? Have you checked that this is true for more than just the one sound file?

Just double-checking, so don't shout at me in the comments. =)

Jonathan
Just realizing I probably should have done that in a comment... Oops. =/
Jonathan
Thanks, Jonathan. Midi files do not contain the sounds, they only contain information about instruments and about when to start and end a note. And yes, I have checked with different files, and they all work well with other players (see my question). I would really appreciate if you could delete your answer and add it as a comment instead - questions without answers usually get more attention :)
Peter Lang