LMMS
Loading...
Searching...
No Matches
juce_MPEZoneLayout.h
Go to the documentation of this file.
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
23namespace juce
24{
25
26//==============================================================================
39struct MPEZone
40{
41 enum class Type { lower, upper };
42
43 MPEZone() = default;
44
45 MPEZone (Type type, int memberChannels = 0, int perNotePitchbend = 48, int masterPitchbend = 2)
46 : zoneType (type),
47 numMemberChannels (memberChannels),
48 perNotePitchbendRange (perNotePitchbend),
49 masterPitchbendRange (masterPitchbend)
50 {}
51
54
56
61
62 bool isUsingChannelAsMemberChannel (int channel) const noexcept
63 {
64 return isLowerZone() ? (lowerZoneMasterChannel < channel && channel <= getLastMemberChannel())
65 : (channel < upperZoneMasterChannel && getLastMemberChannel() <= channel);
66 }
67
68 bool isUsing (int channel) const noexcept
69 {
70 return isUsingChannelAsMemberChannel (channel) || channel == getMasterChannel();
71 }
72
73 static auto tie (const MPEZone& z)
74 {
75 return std::tie (z.zoneType,
76 z.numMemberChannels,
77 z.perNotePitchbendRange,
78 z.masterPitchbendRange);
79 }
80
81 bool operator== (const MPEZone& other) const
82 {
83 return tie (*this) == tie (other);
84 }
85
86 bool operator!= (const MPEZone& other) const
87 {
88 return tie (*this) != tie (other);
89 }
90
91 //==============================================================================
92 static constexpr int lowerZoneMasterChannel = 1,
94
96
100};
101
102//==============================================================================
121{
122public:
123 //==============================================================================
125 MPEZoneLayout() = default;
126
128 MPEZoneLayout (MPEZone lower, MPEZone upper);
129
131 MPEZoneLayout (MPEZone singleZone);
132
133 MPEZoneLayout (const MPEZoneLayout& other);
134 MPEZoneLayout& operator= (const MPEZoneLayout& other);
135
136 bool operator== (const MPEZoneLayout& other) const { return lowerZone == other.lowerZone && upperZone == other.upperZone; }
137 bool operator!= (const MPEZoneLayout& other) const { return ! operator== (other); }
138
139 //==============================================================================
142
145
147 void setLowerZone (int numMemberChannels = 0,
148 int perNotePitchbendRange = 48,
149 int masterPitchbendRange = 2) noexcept;
150
152 void setUpperZone (int numMemberChannels = 0,
153 int perNotePitchbendRange = 48,
154 int masterPitchbendRange = 2) noexcept;
155
159 void clearAllZones();
160
162 bool isActive() const { return lowerZone.isActive() || upperZone.isActive(); }
163
164 //==============================================================================
176 void processNextMidiEvent (const MidiMessage& message);
177
189 void processNextMidiBuffer (const MidiBuffer& buffer);
190
191 //==============================================================================
196 {
197 public:
199 virtual ~Listener() = default;
200
205 virtual void zoneLayoutChanged (const MPEZoneLayout& layout) = 0;
206 };
207
208 //==============================================================================
210 void addListener (Listener* const listenerToAdd) noexcept;
211
213 void removeListener (Listener* const listenerToRemove) noexcept;
214
215 #ifndef DOXYGEN
216 using Zone = MPEZone;
217 #endif
218
219private:
220 //==============================================================================
223
226
227 //==============================================================================
228 void setZone (bool, int, int, int) noexcept;
229
233
234 void updateMasterPitchbend (MPEZone&, int);
236
238 void checkAndLimitZoneParameters (int, int, int&) noexcept;
239};
240
241} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
static void message(int level, const char *fmt,...)
Definition adplugdb.cpp:120
Definition juce_ListenerList.h:70
Definition juce_MPEZoneLayout.h:196
virtual void zoneLayoutChanged(const MPEZoneLayout &layout)=0
virtual ~Listener()=default
void updateMasterPitchbend(MPEZone &, int)
Definition juce_MPEZoneLayout.cpp:141
ListenerList< Listener > listeners
Definition juce_MPEZoneLayout.h:225
MPEZone getUpperZone() const noexcept
Definition juce_MPEZoneLayout.h:144
void processRpnMessage(MidiRPNMessage)
Definition juce_MPEZoneLayout.cpp:122
MPEZoneLayout()=default
void updatePerNotePitchbendRange(MPEZone &, int)
Definition juce_MPEZoneLayout.cpp:151
MPEZone upperZone
Definition juce_MPEZoneLayout.h:222
void sendLayoutChangeMessage()
Definition juce_MPEZoneLayout.cpp:54
MidiRPNDetector rpnDetector
Definition juce_MPEZoneLayout.h:224
void checkAndLimitZoneParameters(int, int, int &) noexcept
Definition juce_MPEZoneLayout.cpp:198
MPEZone Zone
Definition juce_MPEZoneLayout.h:216
void processPitchbendRangeRpnMessage(MidiRPNMessage)
Definition juce_MPEZoneLayout.cpp:161
void removeListener(Listener *const listenerToRemove) noexcept
Definition juce_MPEZoneLayout.cpp:192
void processZoneLayoutRpnMessage(MidiRPNMessage)
Definition juce_MPEZoneLayout.cpp:130
void addListener(Listener *const listenerToAdd) noexcept
Definition juce_MPEZoneLayout.cpp:187
bool isActive() const
Definition juce_MPEZoneLayout.h:162
MPEZone lowerZone
Definition juce_MPEZoneLayout.h:221
void setZone(bool, int, int, int) noexcept
Definition juce_MPEZoneLayout.cpp:60
MPEZone getLowerZone() const noexcept
Definition juce_MPEZoneLayout.h:141
Definition juce_MidiBuffer.h:145
Definition juce_MidiMessage.h:35
Definition juce_MidiRPN.h:68
unsigned z
Definition inflate.c:1589
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
Definition juce_MPEZoneLayout.h:40
int masterPitchbendRange
Definition juce_MPEZoneLayout.h:99
bool isActive() const noexcept
Definition juce_MPEZoneLayout.h:55
static constexpr int upperZoneMasterChannel
Definition juce_MPEZoneLayout.h:93
static constexpr int lowerZoneMasterChannel
Definition juce_MPEZoneLayout.h:92
bool isUsing(int channel) const noexcept
Definition juce_MPEZoneLayout.h:68
Type zoneType
Definition juce_MPEZoneLayout.h:95
int perNotePitchbendRange
Definition juce_MPEZoneLayout.h:98
int getMasterChannel() const noexcept
Definition juce_MPEZoneLayout.h:57
int getLastMemberChannel() const noexcept
Definition juce_MPEZoneLayout.h:59
bool isLowerZone() const noexcept
Definition juce_MPEZoneLayout.h:52
MPEZone(Type type, int memberChannels=0, int perNotePitchbend=48, int masterPitchbend=2)
Definition juce_MPEZoneLayout.h:45
static auto tie(const MPEZone &z)
Definition juce_MPEZoneLayout.h:73
int getFirstMemberChannel() const noexcept
Definition juce_MPEZoneLayout.h:58
bool isUpperZone() const noexcept
Definition juce_MPEZoneLayout.h:53
bool isUsingChannelAsMemberChannel(int channel) const noexcept
Definition juce_MPEZoneLayout.h:62
Type
Definition juce_MPEZoneLayout.h:41
@ upper
Definition juce_MPEZoneLayout.h:41
@ lower
Definition juce_MPEZoneLayout.h:41
int numMemberChannels
Definition juce_MPEZoneLayout.h:97
MPEZone()=default
Definition juce_MidiRPN.h:33
#define const
Definition zconf.h:137