From 300cb139e9009f1675300791cab32432d0ad35a7 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Mon, 10 Oct 2016 14:23:50 +0200 Subject: [PATCH] #54: Deprecated sending of TuneRequests with sendRealTime. --- src/MIDI.hpp | 22 +++++++++---------- .../tests/unit-tests_MidiOutput.cpp | 9 ++++---- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 570c759..7c59a72 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -176,7 +176,7 @@ void MidiInterface::send(MidiType inType, mSerial.write(inData2); } } - else if (inType >= TuneRequest && inType <= SystemReset) + else if (inType >= Clock && inType <= SystemReset) { sendRealTime(inType); // System Real-time and 1 byte. } @@ -344,7 +344,12 @@ void MidiInterface::sendSysEx(unsigned inLength, template void MidiInterface::sendTuneRequest() { - sendRealTime(TuneRequest); + mSerial.write(TuneRequest); + + if (Settings::UseRunningStatus) + { + mRunningStatus_TX = InvalidType; + } } /*! \brief Send a MIDI Time Code Quarter Frame. @@ -412,15 +417,16 @@ void MidiInterface::sendSongSelect(DataByte inSongNumber) \param inType The available Real Time types are: Start, Stop, Continue, Clock, ActiveSensing and SystemReset. - You can also send a Tune Request with this method. @see MidiType */ template void MidiInterface::sendRealTime(MidiType inType) { + // Do not invalidate Running Status for real-time messages + // as they can be interleaved within any message. + switch (inType) { - case TuneRequest: // Not really real-time, but one byte anyway. case Clock: case Start: case Stop: @@ -433,14 +439,6 @@ void MidiInterface::sendRealTime(MidiType inType) // Invalid Real Time marker break; } - - // Do not cancel Running Status for real-time messages as they can be - // interleaved within any message. Though, TuneRequest can be sent here, - // and as it is a System Common message, it must reset Running Status. - if (Settings::UseRunningStatus && inType == TuneRequest) - { - mRunningStatus_TX = InvalidType; - } } /*! \brief Start a Registered Parameter Number frame. diff --git a/test/unit-tests/tests/unit-tests_MidiOutput.cpp b/test/unit-tests/tests/unit-tests_MidiOutput.cpp index e340287..fc4a2ea 100644 --- a/test/unit-tests/tests/unit-tests_MidiOutput.cpp +++ b/test/unit-tests/tests/unit-tests_MidiOutput.cpp @@ -126,10 +126,9 @@ TEST(MidiOutput, sendGenericRealTimeShortcut) SerialMock serial; MidiInterface midi(serial); Buffer buffer; - buffer.resize(7); + buffer.resize(6); midi.begin(); - midi.send(midi::TuneRequest, 47, 42, 12); midi.send(midi::Clock, 47, 42, 12); midi.send(midi::Start, 47, 42, 12); midi.send(midi::Continue, 47, 42, 12); @@ -137,9 +136,9 @@ TEST(MidiOutput, sendGenericRealTimeShortcut) midi.send(midi::ActiveSensing, 47, 42, 12); midi.send(midi::SystemReset, 47, 42, 12); - EXPECT_EQ(serial.mTxBuffer.getLength(), 7); - serial.mTxBuffer.read(&buffer[0], 7); - EXPECT_THAT(buffer, ElementsAreArray({0xf6, 0xf8, 0xfa, 0xfb, 0xfc, 0xfe, 0xff})); + EXPECT_EQ(serial.mTxBuffer.getLength(), 6); + serial.mTxBuffer.read(&buffer[0], 6); + EXPECT_THAT(buffer, ElementsAreArray({0xf8, 0xfa, 0xfb, 0xfc, 0xfe, 0xff})); } // --