OpenShot Audio Library | OpenShotAudio: juce_MPEZoneLayout.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
juce_MPEZoneLayout.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
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
23namespace juce
24{
25
26//==============================================================================
44 class JUCE_API MPEZoneLayout
45{
46public:
56 MPEZoneLayout() noexcept;
57
61 MPEZoneLayout (const MPEZoneLayout& other);
62
66 MPEZoneLayout& operator= (const MPEZoneLayout& other);
67
68 //==============================================================================
81 struct Zone
82 {
83 Zone (const Zone& other) = default;
84
85 bool isLowerZone() const noexcept { return lowerZone; }
86 bool isUpperZone() const noexcept { return ! lowerZone; }
87
88 bool isActive() const noexcept { return numMemberChannels > 0; }
89
90 int getMasterChannel() const noexcept { return lowerZone ? 1 : 16; }
91 int getFirstMemberChannel() const noexcept { return lowerZone ? 2 : 15; }
92 int getLastMemberChannel() const noexcept { return lowerZone ? (1 + numMemberChannels)
93 : (16 - numMemberChannels); }
94
95 bool isUsingChannelAsMemberChannel (int channel) const noexcept
96 {
97 return lowerZone ? (channel > 1 && channel <= 1 + numMemberChannels)
98 : (channel < 16 && channel >= 16 - numMemberChannels);
99 }
100
101 bool isUsing (int channel) const noexcept
102 {
103 return isUsingChannelAsMemberChannel (channel) || channel == getMasterChannel();
104 }
105
106 bool operator== (const Zone& other) const noexcept { return lowerZone == other.lowerZone
107 && numMemberChannels == other.numMemberChannels
108 && perNotePitchbendRange == other.perNotePitchbendRange
109 && masterPitchbendRange == other.masterPitchbendRange; }
110
111 bool operator!= (const Zone& other) const noexcept { return ! operator== (other); }
112
113 int numMemberChannels;
114 int perNotePitchbendRange;
115 int masterPitchbendRange;
116
117 private:
118 friend class MPEZoneLayout;
119
120 Zone (bool lower, int memberChans = 0, int perNotePb = 48, int masterPb = 2) noexcept
121 : numMemberChannels (memberChans),
122 perNotePitchbendRange (perNotePb),
123 masterPitchbendRange (masterPb),
124 lowerZone (lower)
125 {
126 }
127
128 bool lowerZone;
129 };
130
132 void setLowerZone (int numMemberChannels = 0,
133 int perNotePitchbendRange = 48,
134 int masterPitchbendRange = 2) noexcept;
135
137 void setUpperZone (int numMemberChannels = 0,
138 int perNotePitchbendRange = 48,
139 int masterPitchbendRange = 2) noexcept;
140
142 const Zone getLowerZone() const noexcept { return lowerZone; }
143
145 const Zone getUpperZone() const noexcept { return upperZone; }
146
150 void clearAllZones();
151
152 //==============================================================================
164 void processNextMidiEvent (const MidiMessage& message);
165
177 void processNextMidiBuffer (const MidiBuffer& buffer);
178
179 //==============================================================================
183 class Listener
184 {
185 public:
187 virtual ~Listener() = default;
188
193 virtual void zoneLayoutChanged (const MPEZoneLayout& layout) = 0;
194 };
195
196 //==============================================================================
198 void addListener (Listener* const listenerToAdd) noexcept;
199
201 void removeListener (Listener* const listenerToRemove) noexcept;
202
203private:
204 //==============================================================================
205 Zone lowerZone { true, 0 };
206 Zone upperZone { false, 0 };
207
208 MidiRPNDetector rpnDetector;
209 ListenerList<Listener> listeners;
210
211 //==============================================================================
212 void setZone (bool, int, int, int) noexcept;
213
214 void processRpnMessage (MidiRPNMessage);
215 void processZoneLayoutRpnMessage (MidiRPNMessage);
216 void processPitchbendRangeRpnMessage (MidiRPNMessage);
217
218 void updateMasterPitchbend (Zone&, int);
219 void updatePerNotePitchbendRange (Zone&, int);
220
221 void sendLayoutChangeMessage();
222 void checkAndLimitZoneParameters (int, int, int&) noexcept;
223};
224
225} // namespace juce
juce::MPEZoneLayout::Listener
Definition: juce_MPEZoneLayout.h:184
juce::MPEZoneLayout::Listener::zoneLayoutChanged
virtual void zoneLayoutChanged(const MPEZoneLayout &layout)=0
juce::MPEZoneLayout::Listener::~Listener
virtual ~Listener()=default
juce::MPEZoneLayout
Definition: juce_MPEZoneLayout.h:45
juce::MPEZoneLayout::getUpperZone
const Zone getUpperZone() const noexcept
Definition: juce_MPEZoneLayout.h:145
juce::MidiBuffer
Definition: juce_MidiBuffer.h:43
juce::MidiMessage
Definition: juce_MidiMessage.h:35
juce::MPEZoneLayout::Zone
Definition: juce_MPEZoneLayout.h:82