Hi! I've been searching for a solution to my problem for almost a week now. I'm new to Java so I was hoping someone here could help me out!
I'm familiar with a few other programming languages and I got all the "Hello World" stuff going, but the MIDI synthesis in Java is stumping me. Maybe it's just my computer that's the problem, but I'm not sure.
I'm using Eclipse for programming.
Inside my miditest.java file I have a miditest class with this code in it...
Code:
import javax.sound.midi.*;
class miditest
{
public static void main(String[] args) {
MidiDevice.Info[] mdi = MidiSystem.getMidiDeviceInfo();
Synthesizer synth = MidiSystem.getSynthesizer();
synth.close();
synth.open();
final MidiChannel[] mc = synth.getChannels();
Instrument[] instr = synth.getDefaultSoundbank().getInstruments();
synth.loadInstrument(instr[90]);
mc[5].noteOn(60,600);
synth.close();
}
}
At "MidiSystem.getSynthesizer()" it's throwing "MidiUnavailableException". It's throwing that at "synth.open()" too.
I've checked my MIDI for availability... and I'm assuming since every other program can run MIDI that my device is working fine.
Is the problem that I shouldn't be running this code in... a Class? or should it be an Interface? I'm not sure where to start like this in Java... so maybe I should figure out what those two things are....
Anyway, thanks for any help!