| 1179 | */ |
| 1180 | |
| 1181 | int CsoundMidiOutputBuffer::GetChannel() |
| 1182 | { |
| 1183 | unsigned char st = (unsigned char) 0; |
| 1184 | |
| 1185 | if (bufBytes) { |
| 1186 | csoundLockMutex(mutex_); |
| 1187 | if (bufBytes > 0) { |
| 1188 | int nBytes; |
| 1189 | st = buf[bufReadPos] & (unsigned char) 0xFF; |
| 1190 | nBytes = (int) midiMessageByteCnt[(st & (unsigned char) 0xF8) >> 3]; |
| 1191 | if (nBytes < 2 || bufBytes < nBytes) |
| 1192 | st = (unsigned char) 0; // invalid MIDI data, or system message |
| 1193 | else |
| 1194 | st = (st & (unsigned char) 0x0F) + (unsigned char) 1; |
| 1195 | } |
| 1196 | csoundUnlockMutex(mutex_); |
| 1197 | } |
| 1198 | return (int) st; |
| 1199 | } |
| 1200 | |
| 1201 | /** |
| 1202 | * Returns the first data byte (0 to 127) for the first message in the |
no test coverage detected