import javax.sound.midi.*; public class Rada1{ public static void main(String argumendid[]) throws Exception{ ShortMessage lahti = new ShortMessage(); ShortMessage kinni = 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); 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(lahti, 12)); track.add(new MidiEvent(kinni, 15)); track.add(new MidiEvent(lahti, 16)); track.add(new MidiEvent(kinni, 31)); Sequencer sequencer=MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(sequence); sequencer.start(); } }