-
Notifications
You must be signed in to change notification settings - Fork 135
/
MidiMessage.cpp
1934 lines (1510 loc) · 41.5 KB
/
MidiMessage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Sat Feb 14 20:49:21 PST 2015
// Last Modified: Sun Apr 15 11:11:05 PDT 2018 Added event removal system.
// Filename: midifile/src/MidiMessage.cpp
// Website: http://midifile.sapp.org
// Syntax: C++11
// vim: ts=3 noexpandtab
//
// Description: Storage for bytes of a MIDI message for Standard
// MIDI Files.
//
#include "MidiMessage.h"
#include <vector>
#include <iostream>
#include <iterator>
namespace smf {
//////////////////////////////
//
// MidiMessage::MidiMessage -- Constructor.
//
MidiMessage::MidiMessage(void) : vector<uchar>() {
// do nothing
}
MidiMessage::MidiMessage(int command) : vector<uchar>(1, (uchar)command) {
// do nothing
}
MidiMessage::MidiMessage(int command, int p1) : vector<uchar>(2) {
(*this)[0] = (uchar)command;
(*this)[1] = (uchar)p1;
}
MidiMessage::MidiMessage(int command, int p1, int p2) : vector<uchar>(3) {
(*this)[0] = (uchar)command;
(*this)[1] = (uchar)p1;
(*this)[2] = (uchar)p2;
}
MidiMessage::MidiMessage(const MidiMessage& message) : vector<uchar>() {
(*this) = message;
}
MidiMessage::MidiMessage(const std::vector<uchar>& message) : vector<uchar>() {
setMessage(message);
}
MidiMessage::MidiMessage(const std::vector<char>& message) : vector<uchar>() {
setMessage(message);
}
MidiMessage::MidiMessage(const std::vector<int>& message) : vector<uchar>() {
setMessage(message);
}
//////////////////////////////
//
// MidiMessage::~MidiMessage -- Deconstructor.
//
MidiMessage::~MidiMessage() {
resize(0);
}
//////////////////////////////
//
// MidiMessage::operator= --
//
MidiMessage& MidiMessage::operator=(const MidiMessage& message) {
if (this == &message) {
return *this;
}
(*this) = message;
return *this;
}
MidiMessage& MidiMessage::operator=(const std::vector<uchar>& bytes) {
if (this == &bytes) {
return *this;
}
setMessage(bytes);
return *this;
}
MidiMessage& MidiMessage::operator=(const std::vector<char>& bytes) {
setMessage(bytes);
return *this;
}
MidiMessage& MidiMessage::operator=(const std::vector<int>& bytes) {
setMessage(bytes);
return *this;
}
//////////////////////////////
//
// MidiMessage::setSize -- Change the size of the message byte list.
// If the size is increased, then the new bytes are not initialized
// to any specific values.
//
void MidiMessage::setSize(int asize) {
this->resize(asize);
}
//////////////////////////////
//
// MidiMessage::getSize -- Return the size of the MIDI message bytes.
//
int MidiMessage::getSize(void) const {
return (int)this->size();
}
//////////////////////////////
//
// MidiMessage::setSizeToCommand -- Set the number of parameters if the
// command byte is set in the range from 0x80 to 0xef. Any newly
// added parameter bytes will be set to 0. Commands in the range
// of 0xF) should not use this function, and they will ignore
// modification by this command.
//
int MidiMessage::setSizeToCommand(void) {
int osize = (int)this->size();
if (osize < 1) {
return 0;
}
int command = getCommandNibble();
if (command < 0) {
return 0;
}
int bytecount = 1;
switch (command) {
case 0x80: bytecount = 2; break; // Note Off
case 0x90: bytecount = 2; break; // Note On
case 0xA0: bytecount = 2; break; // Aftertouch
case 0xB0: bytecount = 2; break; // Continuous Controller
case 0xC0: bytecount = 1; break; // Patch Change
case 0xD0: bytecount = 1; break; // Channel Pressure
case 0xE0: bytecount = 2; break; // Pitch Bend
case 0xF0:
default:
return (int)size();
}
if (bytecount + 1 < osize) {
resize(bytecount+1);
for (int i=osize; i<bytecount+1; i++) {
(*this)[i] = 0;
}
}
return (int)size();
}
int MidiMessage::resizeToCommand(void) {
return setSizeToCommand();
}
//////////////////////////////
//
// MidiMessage::getTempoMicro -- Returns the number of microseconds per
// quarter note if the MidiMessage is a tempo meta message.
// Returns -1 if the MIDI message is not a tempo meta message.
//
int MidiMessage::getTempoMicro(void) const {
if (!isTempo()) {
return -1;
} else {
return ((*this)[3] << 16) + ((*this)[4] << 8) + (*this)[5];
}
}
int MidiMessage::getTempoMicroseconds(void) const {
return getTempoMicro();
}
//////////////////////////////
//
// MidiMessage::getTempoSeconds -- Returns the number of seconds per
// quarter note. Returns -1.0 if the MIDI message is not a
// tempo meta message.
//
double MidiMessage::getTempoSeconds(void) const {
int microseconds = getTempoMicroseconds();
if (microseconds < 0) {
return -1.0;
} else {
return (double)microseconds / 1000000.0;
}
}
//////////////////////////////
//
// MidiMessage::getTempoBPM -- Returns the tempo in terms of beats per minute.
// Returns -1 if the MidiMessage is note a tempo meta message.
//
double MidiMessage::getTempoBPM(void) const {
int microseconds = getTempoMicroseconds();
if (microseconds < 0) {
return -1.0;
}
return 60000000.0 / (double)microseconds;
}
//////////////////////////////
//
// MidiMessage::getTempoTPS -- Returns the tempo in terms of ticks per seconds.
//
double MidiMessage::getTempoTPS(int tpq) const {
int microseconds = getTempoMicroseconds();
if (microseconds < 0) {
return -1.0;
} else {
return tpq * 1000000.0 / (double)microseconds;
}
}
//////////////////////////////
//
// MidiMessage::getTempoSPT -- Returns the tempo in terms of seconds per tick.
//
double MidiMessage::getTempoSPT(int tpq) const {
int microseconds = getTempoMicroseconds();
if (microseconds < 0) {
return -1.0;
} else {
return (double)microseconds / 1000000.0 / tpq;
}
}
//////////////////////////////
//
// MidiMessage::isMeta -- Returns true if message is a Meta message
// (when the command byte is 0xff).
//
bool MidiMessage::isMeta(void) const {
if (size() == 0) {
return false;
} else if ((*this)[0] != 0xff) {
return false;
} else if (size() < 3) {
// meta message is ill-formed.
// meta messages must have at least three bytes:
// 0: 0xff == meta message marker
// 1: meta message type
// 2: meta message data bytes to follow
return false;
} else {
return true;
}
}
bool MidiMessage::isMetaMessage(void) const {
return isMeta();
}
//////////////////////////////
//
// MidiMessage::isNoteOff -- Returns true if the command nibble is 0x80
// or if the command nibble is 0x90 with p2=0 velocity.
//
bool MidiMessage::isNoteOff(void) const {
if (size() != 3) {
return false;
} else if (((*this)[0] & 0xf0) == 0x80) {
return true;
} else if ((((*this)[0] & 0xf0) == 0x90) && ((*this)[2] == 0)) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isNoteOn -- Returns true if the command byte is in the 0x90
// range and the velocity is non-zero
//
bool MidiMessage::isNoteOn(void) const {
if (size() != 3) {
return false;
} else if (((*this)[0] & 0xf0) != 0x90) {
return false;
} else if ((*this)[2] == 0) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isNote -- Returns true if either a note-on or a note-off
// message.
//
bool MidiMessage::isNote(void) const {
return isNoteOn() || isNoteOff();
}
//////////////////////////////
//
// MidiMessage::isAftertouch -- Returns true if the command byte is in the 0xA0
// range.
//
bool MidiMessage::isAftertouch(void) const {
if (size() != 3) {
return false;
} else if (((*this)[0] & 0xf0) != 0xA0) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isController -- Returns true if the command byte is in the 0xB0
// range and there are two additional data bytes.
//
bool MidiMessage::isController(void) const {
if (size() != 3) {
return false;
} else if (((*this)[0] & 0xf0) != 0xB0) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isSustain -- Returns true if the MidiMessages is a sustain pedal
// control event. Controller 64 is the sustain pedal for general MIDI.
//
bool MidiMessage::isSustain(void) const {
if (!isController()) {
return false;
}
if (getP1() == 64) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isSustainOn -- Returns true if a sustain-pedal-on control message.
// Sustain-on is a value in the range from 64-127 for controller 64.
//
bool MidiMessage::isSustainOn(void) const {
if (!isSustain()) {
return false;
}
if (getP2() >= 64) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isSustainOff -- Returns true if a sustain-pedal-off control message.
// Sustain-off is a value in the range from 0-63 for controller 64.
//
bool MidiMessage::isSustainOff(void) const {
if (!isSustain()) {
return false;
}
if (getP2() < 64) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isSoft -- Returns true if the MidiMessages is a soft pedal
// control event. Controller 67 is the sustain pedal for general MIDI.
//
bool MidiMessage::isSoft(void) const {
if (!isController()) {
return false;
}
if (getP1() == 67) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isSoftOn -- Returns true if a sustain-pedal-on control message.
// Soft-on is a value in the range from 64-127 for controller 67.
//
bool MidiMessage::isSoftOn(void) const {
if (!isSoft()) {
return false;
}
if (getP2() >= 64) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isSoftOff -- Returns true if a sustain-pedal-off control message.
// Soft-off is a value in the range from 0-63 for controller 67.
//
bool MidiMessage::isSoftOff(void) const {
if (!isSoft()) {
return false;
}
if (getP2() < 64) {
return true;
} else {
return false;
}
}
//////////////////////////////
//
// MidiMessage::isTimbre -- Returns true of a patch change message
// (command nibble 0xc0).
//
bool MidiMessage::isTimbre(void) const {
if (((*this)[0] & 0xf0) != 0xc0) {
return false;
} else if (size() != 2) {
return false;
} else {
return true;
}
}
bool MidiMessage::isPatchChange(void) const {
return isTimbre();
}
//////////////////////////////
//
// MidiMessage::isPressure -- Returns true of a channel pressure message
// (command nibble 0xd0).
//
bool MidiMessage::isPressure(void) const {
if (((*this)[0] & 0xf0) != 0xd0) {
return false;
} else if (size() != 2) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isPitchbend -- Returns true of a pitch-bend message
// (command nibble 0xe0).
//
bool MidiMessage::isPitchbend(void) const {
if (((*this)[0] & 0xf0) != 0xe0) {
return false;
} else if (size() != 3) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isEmpty -- Returns true if size of data array is zero.
//
bool MidiMessage::isEmpty(void) const {
return empty();
}
///////////////////////////////
//
// MidiMessage::getMetaType -- returns the meta-message type for the
// MidiMessage. If the message is not a meta message, then returns
// -1.
//
int MidiMessage::getMetaType(void) const {
if (!isMetaMessage()) {
return -1;
} else {
return (int)(*this)[1];
}
}
//////////////////////////////
//
// MidiMessage::isText -- Returns true if message is a meta
// message describing some text (meta message type 0x01).
//
bool MidiMessage::isText(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x01) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isCopyright -- Returns true if message is a meta
// message describing a copyright notice (meta message type 0x02).
// Copyright messages should be at absolute tick position 0
// (and be the first event in the track chunk as well), but this
// function does not check for those requirements.
//
bool MidiMessage::isCopyright(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x02) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isTrackName -- Returns true if message is a meta
// message describing a track name (meta message type 0x03).
//
bool MidiMessage::isTrackName(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x03) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isInstrumentName -- Returns true if message is a
// meta message describing an instrument name (for the track)
// (meta message type 0x04).
//
bool MidiMessage::isInstrumentName(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x04) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isLyricText -- Returns true if message is a meta message
// describing some lyric text (for karakoke MIDI files)
// (meta message type 0x05).
//
bool MidiMessage::isLyricText(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x05) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isMarkerText -- Returns true if message is a meta message
// describing a marker text (meta message type 0x06).
//
bool MidiMessage::isMarkerText(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x06) {
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isTempo -- Returns true if message is a meta message
// describing tempo (meta message type 0x51).
//
bool MidiMessage::isTempo(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x51) {
return false;
} else if (size() != 6) {
// Meta tempo message can only be 6 bytes long.
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isTimeSignature -- Returns true if message is
// a meta message describing a time signature (meta message
// type 0x58).
//
bool MidiMessage::isTimeSignature(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x58) {
return false;
} else if (size() != 7) {
// Meta time signature message can only be 7 bytes long:
// FF 58 <size> <top> <bot-log-2> <clocks-per-beat> <32nds>
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isKeySignature -- Returns true if message is
// a meta message describing a key signature (meta message
// type 0x59).
//
bool MidiMessage::isKeySignature(void) const {
if (!isMetaMessage()) {
return false;
} else if ((*this)[1] != 0x59) {
return false;
} else if (size() != 5) {
// Meta key signature message can only be 5 bytes long:
// FF 59 <size> <accid> <mode>
return false;
} else {
return true;
}
}
//////////////////////////////
//
// MidiMessage::isEndOfTrack -- Returns true if message is a meta message
// for end-of-track (meta message type 0x2f).
//
bool MidiMessage::isEndOfTrack(void) const {
return getMetaType() == 0x2f ? 1 : 0;
}
//////////////////////////////
//
// MidiMessage::getP0 -- Return index 1 byte, or -1 if it doesn't exist.
//
int MidiMessage::getP0(void) const {
return size() < 1 ? -1 : (*this)[0];
}
//////////////////////////////
//
// MidiMessage::getP1 -- Return index 1 byte, or -1 if it doesn't exist.
//
int MidiMessage::getP1(void) const {
return size() < 2 ? -1 : (*this)[1];
}
//////////////////////////////
//
// MidiMessage::getP2 -- Return index 2 byte, or -1 if it doesn't exist.
//
int MidiMessage::getP2(void) const {
return size() < 3 ? -1 : (*this)[2];
}
//////////////////////////////
//
// MidiMessage::getP3 -- Return index 3 byte, or -1 if it doesn't exist.
//
int MidiMessage::getP3(void) const {
return size() < 4 ? -1 : (*this)[3];
}
//////////////////////////////
//
// MidiMessage::getKeyNumber -- Return the key number (such as 60 for
// middle C). If the message does not have a note parameter, then
// return -1; if the key is invalid (above 127 in value), then
// limit to the range 0 to 127.
//
int MidiMessage::getKeyNumber(void) const {
if (isNote() || isAftertouch()) {
int output = getP1();
if (output < 0) {
return output;
} else {
return 0xff & output;
}
} else {
return -1;
}
}
//////////////////////////////
//
// MidiMessage::getVelocity -- Return the key veolocity. If the message
// is not a note-on or a note-off, then return -1. If the value is
// out of the range 0-127, then chop off the high-bits.
//
int MidiMessage::getVelocity(void) const {
if (isNote()) {
int output = getP2();
if (output < 0) {
return output;
} else {
return 0xff & output;
}
} else {
return -1;
}
}
//////////////////////////////
//
// MidiMessage::getControllerNumber -- Return the controller number (such as 1
// for modulation wheel). If the message does not have a controller number
// parameter, then return -1. If the controller number is invalid (above 127
// in value), then limit the range to to 0-127.
//
int MidiMessage::getControllerNumber(void) const {
if (isController()) {
int output = getP1();
if (output < 0) {
// -1 means no P1, although isController() is false in such a case.
return output;
} else {
return 0x7f & output;
}
} else {
return -1;
}
}
//////////////////////////////
//
// MidiMessage::getControllerValue -- Return the controller value. If the
// message is not a control change message, then return -1. If the value is
// out of the range 0-127, then chop off the high-bits.
//
int MidiMessage::getControllerValue(void) const {
if (isController()) {
int output = getP2();
if (output < 0) {
// -1 means no P2, although isController() is false in such a case.
return output;
} else {
return 0x7f & output;
}
} else {
return -1;
}
}
//////////////////////////////
//
// MidiMessage::setP0 -- Set the command byte.
// If the MidiMessage is too short, add extra spaces to
// allow for P0. The value should be in the range from
// 128 to 255, but this function will not babysit you.
//
void MidiMessage::setP0(int value) {
if (getSize() < 1) {
resize(1);
}
(*this)[0] = value;
}
//////////////////////////////
//
// MidiMessage::setP1 -- Set the first parameter value.
// If the MidiMessage is too short, add extra spaces to
// allow for P1. The command byte will be undefined if
// it was added. The value should be in the range from
// 0 to 127, but this function will not babysit you.
//
void MidiMessage::setP1(int value) {
if (getSize() < 2) {
resize(2);
}
(*this)[1] = value;
}
//////////////////////////////
//
// MidiMessage::setP2 -- Set the second paramter value.
// If the MidiMessage is too short, add extra spaces
// to allow for P2. The command byte and/or the P1 value
// will be undefined if extra space needs to be added and
// those slots are created. The value should be in the range
// from 0 to 127, but this function will not babysit you.
//
void MidiMessage::setP2(int value) {
if (getSize() < 3) {
resize(3);
}
(*this)[2] = value;
}
//////////////////////////////
//
// MidiMessage::setP3 -- Set the third paramter value.
// If the MidiMessage is too short, add extra spaces
// to allow for P3. The command byte and/or the P1/P2 values
// will be undefined if extra space needs to be added and
// those slots are created. The value should be in the range
// from 0 to 127, but this function will not babysit you.
//
void MidiMessage::setP3(int value) {
if (getSize() < 4) {
resize(4);
}
(*this)[3] = value;
}
//////////////////////////////
//
// MidiMessage::setKeyNumber -- Set the note on/off key number (or