B
bryan.crompton
Hello,
I've been having a little trouble working with the Java midi
synthesizer included with the API.
I found a peice of code on a forum something like what follows:
import java.util.*;
import javax.sound.midi.*;
class SoundTest
{
public static void main(String[] args) {
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
final MidiChannel[] mc = synth.getChannels();
Instrument[] instr =
synth.getAvailableInstruments();
synth.loadInstrument(instr[55]);
for (int i = 20; i < 80; ++i) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {}
mc[4].noteOn(i,100);
}
} catch (MidiUnavailableException e) {}
}
}
Though I'm not very familier with the sound API (I've just come
accross it today), I'm not confused with the code. The problem is, I
would expect, when modifying the line
"synth.loadInstrument(instr[55]);" to get a different instrument, but
I haven't.
Can anyone help me out?
-Bryan
I've been having a little trouble working with the Java midi
synthesizer included with the API.
I found a peice of code on a forum something like what follows:
import java.util.*;
import javax.sound.midi.*;
class SoundTest
{
public static void main(String[] args) {
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
final MidiChannel[] mc = synth.getChannels();
Instrument[] instr =
synth.getAvailableInstruments();
synth.loadInstrument(instr[55]);
for (int i = 20; i < 80; ++i) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {}
mc[4].noteOn(i,100);
}
} catch (MidiUnavailableException e) {}
}
}
Though I'm not very familier with the sound API (I've just come
accross it today), I'm not confused with the code. The problem is, I
would expect, when modifying the line
"synth.loadInstrument(instr[55]);" to get a different instrument, but
I haven't.
Can anyone help me out?
-Bryan