I have made a java program that synthesises sounds using the MIDI package in the java sound API, however, when I export it to a .jar file, the sound played is quite different to what it is when I run it in eclipse. Does anyone know why it is doing this or how to fix this problem?
A list of the instruments can be found here: http://www.hittrax.com.au/images/artists/gmgs.pdf
Below is a section of my code
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
MidiChannel[] channels = synth.getChannels();
channels[0].programChange(123); // Set the instrument to be played (integer between 0 and 127)
channels[0].noteOn(60, 80); // Play Middle C
Thread.sleep(duration);
channels[0].noteOff(60);
Thread.sleep(500);
synth.close();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (MidiUnavailableException e) {
e.printStackTrace();
}
The image below shows the audio when I record it, the first one is what the sound should be as on eclipse, the second one is what the sound is when exported to a .jar