Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » problems with allegro's midi

This thread is locked; no one can reply to it. rss feed Print
problems with allegro's midi
Mark Oates
Member #1,146
March 2001
avatar

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 
3void 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 
15void 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 
2Time
3Stamp Port Chan Event Data 1 Data 2 Flags
4==============================================================================================
572649 1 1 Note On C3 32 (velocity) 0x0
672649 1 1 Controller Change 7 Channel Volume (7) 0 0x0
772649 1 2 Controller Change 7 Channel Volume (7) 0 0x0
872649 1 3 Controller Change 7 Channel Volume (7) 0 0x0
972649 1 4 Controller Change 7 Channel Volume (7) 0 0x0
1072649 1 5 Controller Change 7 Channel Volume (7) 0 0x0
1172649 1 6 Controller Change 7 Channel Volume (7) 0 0x0
1272649 1 7 Controller Change 7 Channel Volume (7) 0 0x0
1372649 1 8 Controller Change 7 Channel Volume (7) 0 0x0
1472649 1 9 Controller Change 7 Channel Volume (7) 0 0x0
1572649 1 10 Controller Change 7 Channel Volume (7) 0 0x0
1672649 1 11 Controller Change 7 Channel Volume (7) 0 0x0
1772649 1 12 Controller Change 7 Channel Volume (7) 0 0x0
1872649 1 13 Controller Change 7 Channel Volume (7) 0 0x0
1972649 1 14 Controller Change 7 Channel Volume (7) 0 0x0
2072649 1 15 Controller Change 7 Channel Volume (7) 0 0x0
2172649 1 16 Controller Change 7 Channel Volume (7) 0 0x0
2272649 1 1 Controller Change All Notes Off (123) 0 0x0
2372649 1 1 Controller Change All Sounds Off (120) 0 0x0
2472649 1 2 Controller Change All Notes Off (123) 0 0x0
2572649 1 2 Controller Change All Sounds Off (120) 0 0x0
2672649 1 3 Controller Change All Notes Off (123) 0 0x0
2772649 1 3 Controller Change All Sounds Off (120) 0 0x0
2872649 1 4 Controller Change All Notes Off (123) 0 0x0
2972649 1 4 Controller Change All Sounds Off (120) 0 0x0
3072649 1 5 Controller Change All Notes Off (123) 0 0x0
3172649 1 5 Controller Change All Sounds Off (120) 0 0x0
3272649 1 6 Controller Change All Notes Off (123) 0 0x0
33 
34Time
35Stamp Port Chan Event Data 1 Data 2 Flags
36==============================================================================================
3772649 1 6 Controller Change All Sounds Off (120) 0 0x0
3872649 1 7 Controller Change All Notes Off (123) 0 0x0
3972649 1 7 Controller Change All Sounds Off (120) 0 0x0
4072649 1 8 Controller Change All Notes Off (123) 0 0x0
4172649 1 8 Controller Change All Sounds Off (120) 0 0x0
4272649 1 9 Controller Change All Notes Off (123) 0 0x0
4372649 1 9 Controller Change All Sounds Off (120) 0 0x0
4472649 1 10 Controller Change All Notes Off (123) 0 0x0
4572649 1 10 Controller Change All Sounds Off (120) 0 0x0
4672649 1 11 Controller Change All Notes Off (123) 0 0x0
4772649 1 11 Controller Change All Sounds Off (120) 0 0x0
4872649 1 12 Controller Change All Notes Off (123) 0 0x0
4972649 1 12 Controller Change All Sounds Off (120) 0 0x0
5072649 1 13 Controller Change All Notes Off (123) 0 0x0
5172649 1 13 Controller Change All Sounds Off (120) 0 0x0
5272649 1 14 Controller Change All Notes Off (123) 0 0x0
5372649 1 14 Controller Change All Sounds Off (120) 0 0x0
5472649 1 15 Controller Change All Notes Off (123) 0 0x0
5572649 1 15 Controller Change All Sounds Off (120) 0 0x0
5672649 1 16 Controller Change All Notes Off (123) 0 0x0
5772649 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? ???

Go to: