MIDI:Musical Instrument Digtial Interface
Five Steps:
1.Gets a Sequencer and open it
Sequencer player=MidiSystem.getSequencer();
player.open();
2. Make a new Sequence
Sequence seq=new Sequence(timing,4);
3.Get a new Track from the Sequence;
Track t=seq.CreateTrack();
4.Fill the Track with MidiEvents and give the Sequence to the Sequencer
t.add(myMidiEvent1);
player.setSequence(seq);
Example:
import javax.sound.midi.*; public class Untitled927 { |
Make a MidiEvent (song data)
1.Make a Message
ShortMessage a =new ShortMessage();
2.put the Instruction in the Message
a.setMessage(114,1,44,100);
3.Make a new MidiEvent using the Message
MidiEvent noteon=new MidiEvent (a,1);
4.Add the MidiEvent to the Track
track.add(noteon);
Midi message :the heart of a MidiEvent
a.setMessage(Message type,channel,note to play, velocity);