Skip to content

Commit

Permalink
#54: Deprecated sending of TuneRequests with sendRealTime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Best committed Oct 10, 2016
1 parent ac1925a commit 300cb13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
22 changes: 10 additions & 12 deletions src/MIDI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void MidiInterface<SerialPort, Settings>::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.
}
Expand Down Expand Up @@ -344,7 +344,12 @@ void MidiInterface<SerialPort, Settings>::sendSysEx(unsigned inLength,
template<class SerialPort, class Settings>
void MidiInterface<SerialPort, Settings>::sendTuneRequest()
{
sendRealTime(TuneRequest);
mSerial.write(TuneRequest);

if (Settings::UseRunningStatus)
{
mRunningStatus_TX = InvalidType;
}
}

/*! \brief Send a MIDI Time Code Quarter Frame.
Expand Down Expand Up @@ -412,15 +417,16 @@ void MidiInterface<SerialPort, Settings>::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<class SerialPort, class Settings>
void MidiInterface<SerialPort, Settings>::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:
Expand All @@ -433,14 +439,6 @@ void MidiInterface<SerialPort, Settings>::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.
Expand Down
9 changes: 4 additions & 5 deletions test/unit-tests/tests/unit-tests_MidiOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,19 @@ 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);
midi.send(midi::Stop, 47, 42, 12);
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}));
}

// --
Expand Down

0 comments on commit 300cb13

Please sign in to comment.