setUpGui(); //Call our setUpGui method
try
{
Sequencer sequencer = MidiSystem.getSequencer(); //Create a new midi system sequencer
sequencer.open(); //Open up the sequencer object we created
sequencer.addControllerEventListener(ml, new int[] {127});
//Add a control event listener using our ml object
Sequence seq = new Sequence(Sequence.PPQ, 4); //Create a new sequence with a type and res
Track track = seq.createTrack(); //Set the track to our new track on seq
int r = 0;
for (int i = 5; i < 61; i += 4)
{
r = (int) ((Math.random() * 50) + 1);
//Picking up the beats and adding our events to the track
//Helps to add our rectangles along with the beat itself
track.add(makeEvent(144, 1, r, 100,i));
track.add(makeEvent(176, 1, 127, 0, i));
track.add(makeEvent(128, 1, r, 100, i + 2));
}
//Set the sequencer's sequence to the Sequence object we created
sequencer.setSequence(seq);
//Set the tempo to beats per minute
sequencer.setTempoInBPM(220);
//Start our sequencer
sequencer.start();
}
catch (Exception ex) //Catch any exceptions and print the stack trace
{