Parses a stream of MIDI data to assemble RPN and NRPN messages from their constituent MIDI CC messages. More...
#include <juce_MidiRPN.h>
Public Member Functions | |
MidiRPNDetector () noexcept=default | |
Constructor. | |
~MidiRPNDetector () noexcept=default | |
Destructor. | |
void | reset () noexcept |
Resets the RPN detector's internal state, so that it forgets about previously received MIDI CC messages. | |
bool | parseControllerMessage (int midiChannel, int controllerNumber, int controllerValue, MidiRPNMessage &result) noexcept |
std::optional< MidiRPNMessage > | tryParse (int midiChannel, int controllerNumber, int controllerValue) |
Takes the next in a stream of incoming MIDI CC messages and returns a MidiRPNMessage if the current message produces a well-formed RPN or NRPN. | |
Parses a stream of MIDI data to assemble RPN and NRPN messages from their constituent MIDI CC messages.
The detector uses the following parsing rules: the parameter number LSB/MSB can be sent/received in either order and must both come before the parameter value; for the parameter value, LSB always has to be sent/received before the value MSB, otherwise it will be treated as 7-bit (MSB only).
|
defaultnoexcept |
Constructor.
|
defaultnoexcept |
Destructor.
|
noexcept |
Resets the RPN detector's internal state, so that it forgets about previously received MIDI CC messages.
|
noexcept |
std::optional< MidiRPNMessage > MidiRPNDetector::tryParse | ( | int | midiChannel, |
int | controllerNumber, | ||
int | controllerValue ) |
Takes the next in a stream of incoming MIDI CC messages and returns a MidiRPNMessage if the current message produces a well-formed RPN or NRPN.
Note that senders are expected to send the MSB before the LSB, but senders are not required to send a LSB at all. Therefore, tryParse() will return a non-null optional on all MSB messages (provided a parameter number has been set), and will also return a non-null optional for each LSB that follows the initial MSB.
This behaviour allows senders to transmit a single MSB followed by multiple LSB messages to facilitate fine-tuning of parameters.
The result of parsing a MSB will always be a 7-bit value. The result of parsing a LSB that follows an MSB will always be a 14-bit value.