import javax.sound.midi.*; public class Rada2{ public static void main(String argumendid[]) throws Exception{ Sequence sequence=new Sequence(Sequence.PPQ, 4); Track track=sequence.createTrack(); ShortMessage algus = new ShortMessage(); algus.setMessage(ShortMessage.PROGRAM_CHANGE, 0, 16, 0); track.add(new MidiEvent(algus, 0)); for(int korgus=40; korgus<100; korgus++){ ShortMessage lahti = new ShortMessage(); ShortMessage kinni = new ShortMessage(); lahti.setMessage(ShortMessage.NOTE_ON, 0, korgus, 93); kinni.setMessage(ShortMessage.NOTE_OFF, 0, korgus, 93); track.add(new MidiEvent(lahti, korgus-40)); track.add(new MidiEvent(kinni, korgus-39)); } final Sequencer sequencer=MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(sequence); sequencer.start(); } }