import javax.sound.midi.*; import java.io.*; public class Rada3{ public static void main(String argumendid[]) throws Exception{ ShortMessage lahti = new ShortMessage(); ShortMessage kinni = new ShortMessage(); ShortMessage lahti3 = new ShortMessage(); ShortMessage kinni3 = new ShortMessage(); ShortMessage algus = new ShortMessage(); algus.setMessage(ShortMessage.PROGRAM_CHANGE, 0, 16, 0); lahti.setMessage(ShortMessage.NOTE_ON, 0, 65, 93); kinni.setMessage(ShortMessage.NOTE_OFF, 0, 65, 93); lahti3.setMessage(ShortMessage.NOTE_ON, 0, 69, 93); kinni3.setMessage(ShortMessage.NOTE_OFF, 0, 69, 93); Sequence sequence=new Sequence(Sequence.PPQ, 4); Track track=sequence.createTrack(); track.add(new MidiEvent(algus, 0)); track.add(new MidiEvent(lahti, 0)); track.add(new MidiEvent(kinni, 4)); track.add(new MidiEvent(lahti, 8)); track.add(new MidiEvent(kinni, 11)); track.add(new MidiEvent(lahti3, 12)); track.add(new MidiEvent(kinni3, 15)); track.add(new MidiEvent(lahti, 16)); track.add(new MidiEvent(kinni, 31)); //Lisage omapoolne noot MidiSystem.write(sequence, 1, new FileOutputStream("piiksud.mid")); } }