JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MPEUtils.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//==============================================================================
38{
39public:
44 MPEChannelAssigner (MPEZoneLayout::Zone zoneToUse);
45
50 MPEChannelAssigner (Range<int> channelRange = Range<int> (1, 17));
51
64 int findMidiChannelForNewNote (int noteNumber) noexcept;
65
70
77 void noteOff (int noteNumber, int midiChannel = -1);
78
80 void allNotesOff();
81
82private:
83 bool isLegacy = false;
85 int channelIncrement, numChannels, firstChannel, lastChannel, midiChannelLastAssigned;
86
87 //==============================================================================
88 struct MidiChannel
89 {
90 Array<int> notes;
91 int lastNotePlayed = -1;
92 bool isFree() const noexcept { return notes.isEmpty(); }
93 };
94 std::array<MidiChannel, 17> midiChannels;
95
96 //==============================================================================
97 int findMidiChannelPlayingClosestNonequalNote (int noteNumber) noexcept;
98};
99
100//==============================================================================
108{
109public:
111 static const uint32 notMPE = 0;
112
114 MPEChannelRemapper (MPEZoneLayout::Zone zoneToRemap);
115
116 //==============================================================================
126 void remapMidiChannelIfNeeded (MidiMessage& message, uint32 mpeSourceID) noexcept;
127
128 //==============================================================================
130 void reset() noexcept;
131
133 void clearChannel (int channel) noexcept;
134
137
138private:
139 MPEZoneLayout::Zone zone;
140
141 int channelIncrement;
142 int firstChannel, lastChannel;
143
144 uint32 sourceAndChannel[17];
145 uint32 lastUsed[17];
146 uint32 counter = 0;
147
148 //==============================================================================
149 bool applyRemapIfExisting (int channel, uint32 sourceAndChannelID, MidiMessage& m) noexcept;
150 int getBestChanToReuse() const noexcept;
151
152 void zeroArrays();
153
154 //==============================================================================
155 bool messageIsNoteData (const MidiMessage& m) { return (*m.getRawData() & 0xf0) != 0xf0; }
156};
157
158} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
Definition juce_Array.h:222
This class handles the assignment of new MIDI notes to member channels of an active MPE zone.
int findMidiChannelForExistingNote(int initialNoteOnNumber) noexcept
If a note has been added using findMidiChannelForNewNote() this will return the channel to which it w...
int findMidiChannelForNewNote(int noteNumber) noexcept
This method will use a set of rules recommended in the MPE specification to determine which member ch...
void noteOff(int noteNumber, int midiChannel=-1)
You must call this method for all note-offs that you receive so that this class can keep track of the...
void allNotesOff()
Call this to clear all currently playing notes.
This class handles the logic for remapping MIDI note messages from multiple MPE sources onto a specif...
void reset() noexcept
Resets all the source & channel combinations.
void remapMidiChannelIfNeeded(MidiMessage &message, uint32 mpeSourceID) noexcept
Remaps the MIDI channel of the specified MIDI message (if necessary).
static const uint32 notMPE
Used to indicate that a particular source & channel combination is not currently using MPE.
void clearChannel(int channel) noexcept
Clears a specified channel of this MPE zone.
void clearSource(uint32 mpeSourceID)
Clears all channels in use by a specified source.
This class represents the current MPE zone layout of a device capable of handling MPE.
Encapsulates a MIDI message.
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned int uint32
A platform-independent 32-bit unsigned integer type.