From 34b37f75e8a66b4ad75ec321367e68c82f609a93 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Fri, 7 Oct 2016 09:50:37 +0200 Subject: [PATCH] Fixed order of DataEntry bytes (MSB first). --- src/MIDI.hpp | 8 +-- .../tests/unit-tests_MidiOutput.cpp | 49 +++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 200580b..570c759 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -471,8 +471,8 @@ inline void MidiInterface::sendRpnValue(unsigned inValue, {; const byte valMsb = 0x7f & (inValue >> 7); const byte valLsb = 0x7f & inValue; - sendControlChange(DataEntryLSB, valLsb, inChannel); sendControlChange(DataEntryMSB, valMsb, inChannel); + sendControlChange(DataEntryLSB, valLsb, inChannel); } /*! \brief Send separate MSB/LSB values for the currently selected RPN number. @@ -485,8 +485,8 @@ inline void MidiInterface::sendRpnValue(byte inMsb, byte inLsb, Channel inChannel) { - sendControlChange(DataEntryLSB, inLsb, inChannel); sendControlChange(DataEntryMSB, inMsb, inChannel); + sendControlChange(DataEntryLSB, inLsb, inChannel); } /* \brief Increment the value of the currently selected RPN number by the specified amount. @@ -551,8 +551,8 @@ inline void MidiInterface::sendNrpnValue(unsigned inValue, {; const byte valMsb = 0x7f & (inValue >> 7); const byte valLsb = 0x7f & inValue; - sendControlChange(DataEntryLSB, valLsb, inChannel); sendControlChange(DataEntryMSB, valMsb, inChannel); + sendControlChange(DataEntryLSB, valLsb, inChannel); } /*! \brief Send separate MSB/LSB values for the currently selected NRPN number. @@ -565,8 +565,8 @@ inline void MidiInterface::sendNrpnValue(byte inMsb, byte inLsb, Channel inChannel) { - sendControlChange(DataEntryLSB, inLsb, inChannel); sendControlChange(DataEntryMSB, inMsb, inChannel); + sendControlChange(DataEntryLSB, inLsb, inChannel); } /* \brief Increment the value of the currently selected NRPN number by the specified amount. diff --git a/test/unit-tests/tests/unit-tests_MidiOutput.cpp b/test/unit-tests/tests/unit-tests_MidiOutput.cpp index a937280..bdcb0c0 100644 --- a/test/unit-tests/tests/unit-tests_MidiOutput.cpp +++ b/test/unit-tests/tests/unit-tests_MidiOutput.cpp @@ -244,4 +244,53 @@ TEST(MidiOutput, sendRealTime) } +TEST(MidiOutput, RPN) +{ + SerialMock serial; + MidiInterface midi(serial); + std::vector buffer; + + // 14-bit Value Single Frame + { + buffer.clear(); + buffer.resize(13); + + midi.begin(); + midi.beginRpn(1242, 12); + midi.sendRpnValue(12345, 12); + midi.endRpn(12); + + EXPECT_EQ(serial.mTxBuffer.getLength(), 13); + serial.mTxBuffer.read(&buffer[0], 13); + EXPECT_THAT(buffer, ElementsAreArray({0xbb, + 0x64, 0x5a, + 0x65, 0x09, + 0x06, 0x60, + 0x26, 0x39, + 0x64, 0x7f, + 0x65, 0x7f})); + } + // MSB/LSB Single Frame + { + + } + // Increment Single Frame + { + + } + // Decrement Single Frame + { + + } + // Multi Frame + { + + } +} + +TEST(MidiOutput, NRPN) +{ + +} + END_UNNAMED_NAMESPACE