/* Kirjutage viisina sisse noodilġik ja kuulake seda. */ import javax.sound.midi.*; public class Rada2{ public static void main(String argumendid[]) throws Exception{ ShortMessage dolahti = new ShortMessage(); ShortMessage dokinni = new ShortMessage(); ShortMessage relahti = new ShortMessage(); ShortMessage rekinni = new ShortMessage(); ShortMessage milahti = new ShortMessage(); ShortMessage mikinni = new ShortMessage(); ShortMessage algus = new ShortMessage(); algus.setMessage(ShortMessage.PROGRAM_CHANGE, 0, 16, 0); dolahti.setMessage(ShortMessage.NOTE_ON, 0, 60, 93); dokinni.setMessage(ShortMessage.NOTE_OFF, 0, 60, 93); relahti.setMessage(ShortMessage.NOTE_ON, 0, 62, 93); rekinni.setMessage(ShortMessage.NOTE_OFF, 0, 62, 93); milahti.setMessage(ShortMessage.NOTE_ON, 0, 64, 93); mikinni.setMessage(ShortMessage.NOTE_OFF, 0, 64, 93); Sequence sequence=new Sequence(Sequence.PPQ, 4); Track track=sequence.createTrack(); track.add(new MidiEvent(algus, 0)); track.add(new MidiEvent(milahti, 0)); track.add(new MidiEvent(mikinni, 3)); track.add(new MidiEvent(milahti, 4)); track.add(new MidiEvent(mikinni, 7)); track.add(new MidiEvent(relahti, 8)); track.add(new MidiEvent(rekinni, 11)); track.add(new MidiEvent(milahti, 12)); track.add(new MidiEvent(mikinni, 15)); track.add(new MidiEvent(dolahti, 16)); track.add(new MidiEvent(dokinni, 19)); track.add(new MidiEvent(dolahti, 20)); track.add(new MidiEvent(dokinni, 23)); track.add(new MidiEvent(dolahti, 24)); track.add(new MidiEvent(dokinni, 31)); Sequencer sequencer=MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(sequence); sequencer.start(); } }