Loading...
Searching...
No Matches
juce_MidiRPN.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
struct MidiRPNMessage
{
int channel;
int parameterNumber;
int value;
bool isNRPN;
bool is14BitValue;
};
//==============================================================================
class JUCE_API MidiRPNDetector
{
public:
MidiRPNDetector() noexcept = default;
~MidiRPNDetector() noexcept = default;
void reset() noexcept;
//==============================================================================
[[deprecated ("Use tryParse() instead")]]
bool parseControllerMessage (int midiChannel,
int controllerNumber,
int controllerValue,
MidiRPNMessage& result) noexcept;
std::optional<MidiRPNMessage> tryParse (int midiChannel,
int controllerNumber,
int controllerValue);
private:
//==============================================================================
struct ChannelState
{
std::optional<MidiRPNMessage> handleController (int channel, int controllerNumber,
int value) noexcept;
void resetValue() noexcept;
std::optional<MidiRPNMessage> sendIfReady (int channel) noexcept;
uint8 parameterMSB = 0xff, parameterLSB = 0xff, valueMSB = 0xff, valueLSB = 0xff;
bool isNRPN = false;
};
//==============================================================================
ChannelState states[16];
JUCE_LEAK_DETECTOR (MidiRPNDetector)
};
//==============================================================================
class JUCE_API MidiRPNGenerator
{
public:
//==============================================================================
static MidiBuffer generate (MidiRPNMessage message);
//==============================================================================
static MidiBuffer generate (int channel,
int parameterNumber,
int value,
bool isNRPN = false,
bool use14BitValue = true);
};
} // namespace juce
juce::MidiBuffer
Definition juce_MidiBuffer.h:145
juce::MidiRPNDetector
Definition juce_MidiRPN.h:68
juce::MidiRPNDetector::parseControllerMessage
bool parseControllerMessage(int midiChannel, int controllerNumber, int controllerValue, MidiRPNMessage &result) noexcept
Definition juce_MidiRPN.cpp:26
juce::MidiRPNDetector::reset
void reset() noexcept
Definition juce_MidiRPN.cpp:51
juce::MidiRPNDetector::tryParse
std::optional< MidiRPNMessage > tryParse(int midiChannel, int controllerNumber, int controllerValue)
Definition juce_MidiRPN.cpp:40
juce::MidiRPNDetector::MidiRPNDetector
MidiRPNDetector() noexcept=default
juce::MidiRPNGenerator
Definition juce_MidiRPN.h:136
juce::MidiRPNGenerator::generate
static MidiBuffer generate(MidiRPNMessage message)
Definition juce_MidiRPN.cpp:114
juce::MidiRPNMessage
Definition juce_MidiRPN.h:33
juce::MidiRPNMessage::isNRPN
bool isNRPN
Definition juce_MidiRPN.h:47
juce::MidiRPNMessage::is14BitValue
bool is14BitValue
Definition juce_MidiRPN.h:52
juce::MidiRPNMessage::channel
int channel
Definition juce_MidiRPN.h:35
juce::MidiRPNMessage::parameterNumber
int parameterNumber
Definition juce_MidiRPN.h:38
juce::MidiRPNMessage::value
int value
Definition juce_MidiRPN.h:44