OpenShot Audio Library | OpenShotAudio  0.6.0
juce_MidiRPN.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2022 - Raw Material Software Limited
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  The code included in this file is provided under the terms of the ISC license
11  http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12  To use, copy, modify, and/or distribute this software for any purpose with or
13  without fee is hereby granted provided that the above copyright notice and
14  this permission notice appear in all copies.
15 
16  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18  DISCLAIMED.
19 
20  ==============================================================================
21 */
22 
23 namespace juce
24 {
25 
26 //==============================================================================
33 {
35  int channel;
36 
39 
44  int value;
45 
47  bool isNRPN;
48 
53 };
54 
55 //==============================================================================
67 class JUCE_API MidiRPNDetector
68 {
69 public:
71  MidiRPNDetector() noexcept = default;
72 
74  ~MidiRPNDetector() noexcept = default;
75 
79  void reset() noexcept;
80 
81  //==============================================================================
83  [[deprecated ("Use tryParse() instead")]]
84  bool parseControllerMessage (int midiChannel,
85  int controllerNumber,
86  int controllerValue,
87  MidiRPNMessage& result) noexcept;
88 
103  std::optional<MidiRPNMessage> tryParse (int midiChannel,
104  int controllerNumber,
105  int controllerValue);
106 
107 private:
108  //==============================================================================
109  struct ChannelState
110  {
111  std::optional<MidiRPNMessage> handleController (int channel, int controllerNumber,
112  int value) noexcept;
113  void resetValue() noexcept;
114  std::optional<MidiRPNMessage> sendIfReady (int channel) noexcept;
115 
116  uint8 parameterMSB = 0xff, parameterLSB = 0xff, valueMSB = 0xff, valueLSB = 0xff;
117  bool isNRPN = false;
118  };
119 
120  //==============================================================================
121  ChannelState states[16];
122 
123  JUCE_LEAK_DETECTOR (MidiRPNDetector)
124 };
125 
126 //==============================================================================
135 class JUCE_API MidiRPNGenerator
136 {
137 public:
138  //==============================================================================
140  static MidiBuffer generate (MidiRPNMessage message);
141 
142  //==============================================================================
159  static MidiBuffer generate (int channel,
160  int parameterNumber,
161  int value,
162  bool isNRPN = false,
163  bool use14BitValue = true);
164 };
165 
166 } // namespace juce
MidiRPNDetector() noexcept=default