MIDI Plugin: Fix BASSMIDI driver SysEx handling

These events were split up in handling after this driver fell out of
use. It needed updating with the latest split handling design.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-09 18:36:37 -08:00
parent 808b14a358
commit b03702e164
2 changed files with 20 additions and 23 deletions

View File

@ -274,29 +274,25 @@ void BMPlayer::setSincInterpolation(bool enable) {
}
void BMPlayer::send_event(uint32_t b) {
if(!(b & 0x80000000)) {
unsigned char event[3];
event[0] = (unsigned char)b;
event[1] = (unsigned char)(b >> 8);
event[2] = (unsigned char)(b >> 16);
unsigned port = (b >> 24) & 0x7F;
unsigned channel = b & 0x0F;
unsigned command = b & 0xF0;
unsigned event_length = (command == 0xC0 || command == 0xD0) ? 2 : 3;
if(port > 2) port = 2;
if(bank_lsb_overridden && command == 0xB0 && event[1] == 0x20) return;
BASS_MIDI_StreamEvents(_stream[port], BASS_MIDI_EVENTS_RAW + 1 + channel, event, event_length);
} else {
uint32_t n = b & 0xffffff;
const uint8_t *data;
std::size_t size, port;
mSysexMap.get_entry(n, data, size, port);
if(port > 2) port = 2;
BASS_MIDI_StreamEvents(_stream[port], BASS_MIDI_EVENTS_RAW, data, (unsigned int)size);
if(port == 0) {
BASS_MIDI_StreamEvents(_stream[1], BASS_MIDI_EVENTS_RAW, data, (unsigned int)size);
BASS_MIDI_StreamEvents(_stream[2], BASS_MIDI_EVENTS_RAW, data, (unsigned int)size);
}
uint8_t event[3];
event[0] = static_cast<uint8_t>(b);
event[1] = static_cast<uint8_t>(b >> 8);
event[2] = static_cast<uint8_t>(b >> 16);
unsigned port = (b >> 24) & 0x7F;
const unsigned channel = b & 0x0F;
const unsigned command = b & 0xF0;
const unsigned event_length = (command >= 0xF8 && command <= 0xFF) ? 1 : ((command == 0xC0 || command == 0xD0) ? 2 : 3);
if(port > 2) port = 0;
if(bank_lsb_overridden && command == 0xB0 && event[1] == 0x20) return;
BASS_MIDI_StreamEvents(_stream[port], BASS_MIDI_EVENTS_RAW + 1 + channel, event, event_length);
}
void BMPlayer::send_sysex(const uint8_t *data, size_t size, size_t port) {
if(port > 2) port = 0;
BASS_MIDI_StreamEvents(_stream[port], BASS_MIDI_EVENTS_RAW, event, static_cast<unsigned int>(size));
if(port == 0) {
BASS_MIDI_StreamEvents(_stream[1], BASS_MIDI_EVENTS_RAW, data, static_cast<unsigned int>(size));
BASS_MIDI_StreamEvents(_stream[2], BASS_MIDI_EVENTS_RAW, data, static_cast<unsigned int>(size));
}
}

View File

@ -22,6 +22,7 @@ class BMPlayer : public MIDIPlayer {
private:
virtual void send_event(uint32_t b);
virtual void send_sysex(const uint8_t* data, size_t size, size_t port);
virtual void render(float* out, unsigned long count);
virtual void shutdown();