Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Midi Input Part 1 #142

Merged
merged 13 commits into from
Oct 22, 2024
55 changes: 35 additions & 20 deletions sources/Services/Midi/MidiInDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,17 @@ void MidiInDevice::Trigger(Time time) {
void MidiInDevice::treatChannelEvent(MidiMessage &event) {

int midiChannel = event.status_ & 0x0F;

bool isMidiClockEvent = (event.status_ == 0xF8);

// Midi clock events happen alot so handle them first to make the codepath shorter
if (isMidiClockEvent) {
// Todo: SL implement midi clock
return;
}

if (!isMidiClockEvent) {
Trace::Debug("midi in:%X:%X:%X",event.status_, event.data1_, event.data2_);
}

switch (event.GetType())
{
Expand Down Expand Up @@ -255,25 +264,31 @@ void MidiInDevice::treatChannelEvent(MidiMessage &event) {
channel->Trigger();
}
}
case MidiMessage::MIDI_START:
{
Trace::Log("EVENT","midi:start");
onMidiStart();
break;
}
case MidiMessage::MIDI_CONTINUE:
{
Trace::Log("EVENT","midi:continue");
onMidiContinue();
break;
}
case MidiMessage::MIDI_STOP:
{
Trace::Log("EVENT","midi:stop");
onMidiStop();
break;
}
case 0xF0: // Midi clock
case MidiMessage::MIDI_MIDI_CLOCK: // Midi clock
// MIDI_START = 0xFA,
// MIDI_CONTINUE = 0xFB,
// MIDI_STOP = 0xFC,
switch (event.status_)
{
case 0xFA:
{
Trace::Log("EVENT","midi:start");
onMidiStart();
break;
}
case 0xFB:
{
Trace::Log("EVENT","midi:continue");
onMidiContinue();
break;
}
case 0xFC:
{
Trace::Log("EVENT","midi:stop");
onMidiStop();
break;
}
}
break;
default:
break;
Expand Down
3 changes: 0 additions & 3 deletions sources/Services/Midi/MidiMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ struct MidiMessage:public I_ObservableData
MIDI_CHANNEL_AFTERTOUCH = 0xD0,
MIDI_PITCH_BEND = 0xE0,
MIDI_MIDI_CLOCK = 0xF0,
MIDI_START = 0xFA,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we get to keep these?

MIDI_CONTINUE = 0xFB,
MIDI_STOP = 0xFC,
};

static const unsigned char UNUSED_BYTE = 255;
Expand Down