1
我有一些筆記,每個都有一個MIDI編號,持續時間和速度。最簡單的輸出簡單MIDI文件的方法?
我目前使用的合成器演奏出音符:
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);
}
不過,現在我想這個保存到一個MIDI文件。什麼是最簡單的方法來做到這一點?
http://www.automatic-pilot.com/midifile.html 這可能會有幫助。 – diegoperini