I have a few notes each with a midi number, duration, and velocity.
I am currently using Synthesizer to play out the notes:
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
MidiChannel[] channels = synthesizer.getChannels();
for(Note n: song)
{
n.playNote(channels[0]);
}
synthesizer.close();
Note.playNote()
public void playNote(MidiChannel c) throws InterruptedException
{
if (type == 'n')
c.noteOn(noteNumber, 60);
Thread.sleep(getLength());
if (type == 'n')
c.noteOff(noteNumber);
}
However, now I would like to save this to a midi file. What’s the simplest way to do this?
One simple procedure is essentially as follows: