I'm writing a sequencer and I'm using allegro's midi routines. Each time I start the program, allegro (or something) throws out midi messages to all 16 channels to set their respective volumes to 0. So I wrote this simple program:
| 1 | #include <allegro.h> |
| 2 | |
| 3 | void note_on(int channel, int pitch, int vel) |
| 4 | { |
| 5 | unsigned char msg[3]; |
| 6 | |
| 7 | msg[0] = 0x90+channel; |
| 8 | msg[1] = pitch; |
| 9 | msg[2] = vel / 2; |
| 10 | |
| 11 | midi_out(msg, 3); |
| 12 | } |
| 13 | |
| 14 | |
| 15 | void main() |
| 16 | { |
| 17 | allegro_init(); |
| 18 | |
| 19 | install_sound(DIGI_NONE, MIDI_AUTODETECT, NULL); |
| 20 | |
| 21 | note_on(0, 60, 64); |
| 22 | |
| 23 | } END_OF_MAIN(); |
and the output of my sampler (Gigastudio) shows the following messages are sent to it once I run the program:
| 1 | |
| 2 | Time |
| 3 | Stamp Port Chan Event Data 1 Data 2 Flags |
| 4 | ============================================================================================== |
| 5 | 72649 1 1 Note On C3 32 (velocity) 0x0 |
| 6 | 72649 1 1 Controller Change 7 Channel Volume (7) 0 0x0 |
| 7 | 72649 1 2 Controller Change 7 Channel Volume (7) 0 0x0 |
| 8 | 72649 1 3 Controller Change 7 Channel Volume (7) 0 0x0 |
| 9 | 72649 1 4 Controller Change 7 Channel Volume (7) 0 0x0 |
| 10 | 72649 1 5 Controller Change 7 Channel Volume (7) 0 0x0 |
| 11 | 72649 1 6 Controller Change 7 Channel Volume (7) 0 0x0 |
| 12 | 72649 1 7 Controller Change 7 Channel Volume (7) 0 0x0 |
| 13 | 72649 1 8 Controller Change 7 Channel Volume (7) 0 0x0 |
| 14 | 72649 1 9 Controller Change 7 Channel Volume (7) 0 0x0 |
| 15 | 72649 1 10 Controller Change 7 Channel Volume (7) 0 0x0 |
| 16 | 72649 1 11 Controller Change 7 Channel Volume (7) 0 0x0 |
| 17 | 72649 1 12 Controller Change 7 Channel Volume (7) 0 0x0 |
| 18 | 72649 1 13 Controller Change 7 Channel Volume (7) 0 0x0 |
| 19 | 72649 1 14 Controller Change 7 Channel Volume (7) 0 0x0 |
| 20 | 72649 1 15 Controller Change 7 Channel Volume (7) 0 0x0 |
| 21 | 72649 1 16 Controller Change 7 Channel Volume (7) 0 0x0 |
| 22 | 72649 1 1 Controller Change All Notes Off (123) 0 0x0 |
| 23 | 72649 1 1 Controller Change All Sounds Off (120) 0 0x0 |
| 24 | 72649 1 2 Controller Change All Notes Off (123) 0 0x0 |
| 25 | 72649 1 2 Controller Change All Sounds Off (120) 0 0x0 |
| 26 | 72649 1 3 Controller Change All Notes Off (123) 0 0x0 |
| 27 | 72649 1 3 Controller Change All Sounds Off (120) 0 0x0 |
| 28 | 72649 1 4 Controller Change All Notes Off (123) 0 0x0 |
| 29 | 72649 1 4 Controller Change All Sounds Off (120) 0 0x0 |
| 30 | 72649 1 5 Controller Change All Notes Off (123) 0 0x0 |
| 31 | 72649 1 5 Controller Change All Sounds Off (120) 0 0x0 |
| 32 | 72649 1 6 Controller Change All Notes Off (123) 0 0x0 |
| 33 | |
| 34 | Time |
| 35 | Stamp Port Chan Event Data 1 Data 2 Flags |
| 36 | ============================================================================================== |
| 37 | 72649 1 6 Controller Change All Sounds Off (120) 0 0x0 |
| 38 | 72649 1 7 Controller Change All Notes Off (123) 0 0x0 |
| 39 | 72649 1 7 Controller Change All Sounds Off (120) 0 0x0 |
| 40 | 72649 1 8 Controller Change All Notes Off (123) 0 0x0 |
| 41 | 72649 1 8 Controller Change All Sounds Off (120) 0 0x0 |
| 42 | 72649 1 9 Controller Change All Notes Off (123) 0 0x0 |
| 43 | 72649 1 9 Controller Change All Sounds Off (120) 0 0x0 |
| 44 | 72649 1 10 Controller Change All Notes Off (123) 0 0x0 |
| 45 | 72649 1 10 Controller Change All Sounds Off (120) 0 0x0 |
| 46 | 72649 1 11 Controller Change All Notes Off (123) 0 0x0 |
| 47 | 72649 1 11 Controller Change All Sounds Off (120) 0 0x0 |
| 48 | 72649 1 12 Controller Change All Notes Off (123) 0 0x0 |
| 49 | 72649 1 12 Controller Change All Sounds Off (120) 0 0x0 |
| 50 | 72649 1 13 Controller Change All Notes Off (123) 0 0x0 |
| 51 | 72649 1 13 Controller Change All Sounds Off (120) 0 0x0 |
| 52 | 72649 1 14 Controller Change All Notes Off (123) 0 0x0 |
| 53 | 72649 1 14 Controller Change All Sounds Off (120) 0 0x0 |
| 54 | 72649 1 15 Controller Change All Notes Off (123) 0 0x0 |
| 55 | 72649 1 15 Controller Change All Sounds Off (120) 0 0x0 |
| 56 | 72649 1 16 Controller Change All Notes Off (123) 0 0x0 |
| 57 | 72649 1 16 Controller Change All Sounds Off (120) 0 0x0 |
It seems to make sense that the "all notes off" commands come as the program is closing, but what's with the volume changes?
In my sequencer program, I noticed that the vol changes are only sent after the first midi message is sent, not when it does the install_sound().
does anybody know what might be causing this?