Taken from Head First Java's book, I am doing a Beatbox, where 16 different instruments have 16 checkboxes you can check, each one of them would be a 'beat' and, if checked, produced sound.
I have a specific method to produce MIDI events:
private MidiEvent makeEvent(int comd, int chan, int one, int two, int tick) {
MidiEvent event = null;
try {
ShortMessage a = new ShortMessage();
a.setMessage(comd, chan, one, two);
event = new MidiEvent(a, tick);
} catch(Exception e) {e.printStackTrace(); }
return event;
Now, at some point in the code, the following comes up:
track.add(makeEvent(176,1,126,0,16));
track.add(makeEvent(192,9,1,0,15));
The first one I don't understand or know what it's for. The second one is according to the book to 'make sure there is an event on beat 16, otherwise the Beatbox might not go the full 16 beats before starting over'.
What are the arguments being passed to the method? Why do I need these two in the code? I found 176 is a CONTROL_CHANGE and 192 PROGRAM_CHANGE, the second argument would be the channel, the third 'note to play' and the fourth 'velocity'.
I tried going through the APIs, and found nothing.