Commit 4e5e7a11 authored by Christian Schoenebeck's avatar Christian Schoenebeck
Browse files

CoreMIDI driver fix: MIDI "running status" was not implemented.

( Added few lines to implement it, transition to
  JackMidiRawInputWriteQueue might be a better solution though )
parent f0b3dfa6
...@@ -39,6 +39,7 @@ JackCoreMidiInputPort::JackCoreMidiInputPort(double time_ratio, ...@@ -39,6 +39,7 @@ JackCoreMidiInputPort::JackCoreMidiInputPort(double time_ratio,
write_queue_ptr.release(); write_queue_ptr.release();
thread_queue_ptr.release(); thread_queue_ptr.release();
jack_event = 0; jack_event = 0;
running_status_buf[0] = 0;
} }
JackCoreMidiInputPort::~JackCoreMidiInputPort() JackCoreMidiInputPort::~JackCoreMidiInputPort()
...@@ -68,6 +69,8 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list) ...@@ -68,6 +69,8 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list)
{ {
set_threaded_log_function(); set_threaded_log_function();
// TODO: maybe parsing should be done by JackMidiRawInputWriteQueue instead
unsigned int packet_count = packet_list->numPackets; unsigned int packet_count = packet_list->numPackets;
assert(packet_count); assert(packet_count);
MIDIPacket *packet = (MIDIPacket *) packet_list->packet; MIDIPacket *packet = (MIDIPacket *) packet_list->packet;
...@@ -116,8 +119,30 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list) ...@@ -116,8 +119,30 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list)
goto buffer_sysex_bytes; goto buffer_sysex_bytes;
} }
} }
event.buffer = data;
event.size = size; // regular status byte ?
if ((data[0] & 0x80) || !running_status_buf[0] ||
(size + 1) > sizeof(running_status_buf))
{ // valid status byte (or invalid "running status") ...
event.buffer = data;
event.size = size;
// store status byte for eventual "running status" in next event
if (data[0] & 0x80) {
if (data[0] < 0xf0) {
// "running status" is only allowed for channel messages
running_status_buf[0] = data[0];
} else if (data[0] < 0xf8) {
// "system common" messages (0xf0..0xf7) shall reset any running
// status, however "realtime" messages (0xf8..0xff) shall be
// ignored here
running_status_buf[0] = 0;
}
}
} else { // "running status" mode ...
memcpy(&running_status_buf[1], data, size);
event.buffer = running_status_buf;
event.size = size + 1;
}
send_event: send_event:
event.time = GetFramesFromTimeStamp(packet->timeStamp); event.time = GetFramesFromTimeStamp(packet->timeStamp);
...@@ -174,6 +199,7 @@ JackCoreMidiInputPort::Start() ...@@ -174,6 +199,7 @@ JackCoreMidiInputPort::Start()
// the engine. // the engine.
while (thread_queue->DequeueEvent()); while (thread_queue->DequeueEvent());
sysex_bytes_sent = 0; sysex_bytes_sent = 0;
running_status_buf[0] = 0;
return true; return true;
} }
......
...@@ -36,6 +36,7 @@ namespace Jack { ...@@ -36,6 +36,7 @@ namespace Jack {
jack_midi_event_t *jack_event; jack_midi_event_t *jack_event;
jack_midi_data_t *sysex_buffer; jack_midi_data_t *sysex_buffer;
size_t sysex_bytes_sent; size_t sysex_bytes_sent;
jack_midi_data_t running_status_buf[3];
JackMidiAsyncQueue *thread_queue; JackMidiAsyncQueue *thread_queue;
JackMidiBufferWriteQueue *write_queue; JackMidiBufferWriteQueue *write_queue;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment