Browse Source

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

( Added few lines to implement it, transition to
  JackMidiRawInputWriteQueue might be a better solution though )
tags/v1.9.10
Christian Schoenebeck 12 years ago
parent
commit
4e5e7a11c3
2 changed files with 29 additions and 2 deletions
  1. +28
    -2
      macosx/coremidi/JackCoreMidiInputPort.cpp
  2. +1
    -0
      macosx/coremidi/JackCoreMidiInputPort.h

+ 28
- 2
macosx/coremidi/JackCoreMidiInputPort.cpp View File

@@ -39,6 +39,7 @@ JackCoreMidiInputPort::JackCoreMidiInputPort(double time_ratio,
write_queue_ptr.release();
thread_queue_ptr.release();
jack_event = 0;
running_status_buf[0] = 0;
}

JackCoreMidiInputPort::~JackCoreMidiInputPort()
@@ -68,6 +69,8 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list)
{
set_threaded_log_function();

// TODO: maybe parsing should be done by JackMidiRawInputWriteQueue instead

unsigned int packet_count = packet_list->numPackets;
assert(packet_count);
MIDIPacket *packet = (MIDIPacket *) packet_list->packet;
@@ -116,8 +119,30 @@ JackCoreMidiInputPort::ProcessCoreMidi(const MIDIPacketList *packet_list)
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:
event.time = GetFramesFromTimeStamp(packet->timeStamp);
@@ -174,6 +199,7 @@ JackCoreMidiInputPort::Start()
// the engine.
while (thread_queue->DequeueEvent());
sysex_bytes_sent = 0;
running_status_buf[0] = 0;
return true;
}



+ 1
- 0
macosx/coremidi/JackCoreMidiInputPort.h View File

@@ -36,6 +36,7 @@ namespace Jack {
jack_midi_event_t *jack_event;
jack_midi_data_t *sysex_buffer;
size_t sysex_bytes_sent;
jack_midi_data_t running_status_buf[3];
JackMidiAsyncQueue *thread_queue;
JackMidiBufferWriteQueue *write_queue;



Loading…
Cancel
Save