.. | .. |
---|
9 | 9 | |
---|
10 | 10 | #include "midibuf.h" |
---|
11 | 11 | |
---|
| 12 | + |
---|
12 | 13 | static int midibuf_message_length(unsigned char code) |
---|
13 | 14 | { |
---|
14 | 15 | int message_length; |
---|
.. | .. |
---|
20 | 21 | |
---|
21 | 22 | message_length = length[(code >> 4) - 8]; |
---|
22 | 23 | } else { |
---|
23 | | - /* |
---|
24 | | - Note that according to the MIDI specification 0xf2 is |
---|
25 | | - the "Song Position Pointer", but this is used by Line 6 |
---|
26 | | - to send sysex messages to the host. |
---|
27 | | - */ |
---|
28 | | - static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1, |
---|
| 24 | + static const int length[] = { -1, 2, 2, 2, -1, -1, 1, 1, 1, -1, |
---|
29 | 25 | 1, 1, 1, -1, 1, 1 |
---|
30 | 26 | }; |
---|
31 | 27 | message_length = length[code & 0x0f]; |
---|
.. | .. |
---|
125 | 121 | } |
---|
126 | 122 | |
---|
127 | 123 | int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, |
---|
128 | | - int length) |
---|
| 124 | + int length, int read_type) |
---|
129 | 125 | { |
---|
130 | 126 | int bytes_used; |
---|
131 | 127 | int length1, length2; |
---|
.. | .. |
---|
148 | 144 | |
---|
149 | 145 | length1 = this->size - this->pos_read; |
---|
150 | 146 | |
---|
151 | | - /* check MIDI command length */ |
---|
152 | 147 | command = this->buf[this->pos_read]; |
---|
| 148 | + /* |
---|
| 149 | + PODxt always has status byte lower nibble set to 0010, |
---|
| 150 | + when it means to send 0000, so we correct if here so |
---|
| 151 | + that control/program changes come on channel 1 and |
---|
| 152 | + sysex message status byte is correct |
---|
| 153 | + */ |
---|
| 154 | + if (read_type == LINE6_MIDIBUF_READ_RX) { |
---|
| 155 | + if (command == 0xb2 || command == 0xc2 || command == 0xf2) { |
---|
| 156 | + unsigned char fixed = command & 0xf0; |
---|
| 157 | + this->buf[this->pos_read] = fixed; |
---|
| 158 | + command = fixed; |
---|
| 159 | + } |
---|
| 160 | + } |
---|
153 | 161 | |
---|
| 162 | + /* check MIDI command length */ |
---|
154 | 163 | if (command & 0x80) { |
---|
155 | 164 | midi_length = midibuf_message_length(command); |
---|
156 | 165 | this->command_prev = command; |
---|