OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_MPEUtils.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//==============================================================================
38{
39public:
45
50 MPEChannelAssigner (Range<int> channelRange = Range<int> (1, 17));
51
64 int findMidiChannelForNewNote (int noteNumber) noexcept;
65
72 void noteOff (int noteNumber, int midiChannel = -1);
73
75 void allNotesOff();
76
77private:
78 bool isLegacy = false;
79 std::unique_ptr<MPEZoneLayout::Zone> zone;
80 int channelIncrement, numChannels, firstChannel, lastChannel, midiChannelLastAssigned;
81
82 //==============================================================================
83 struct MidiChannel
84 {
85 Array<int> notes;
86 int lastNotePlayed = -1;
87 bool isFree() const noexcept { return notes.isEmpty(); }
88 };
89 MidiChannel midiChannels[17];
90
91 //==============================================================================
92 int findMidiChannelPlayingClosestNonequalNote (int noteNumber) noexcept;
93};
94
95//==============================================================================
103{
104public:
106 static const uint32 notMPE = 0;
107
110
111 //==============================================================================
121 void remapMidiChannelIfNeeded (MidiMessage& message, uint32 mpeSourceID) noexcept;
122
123 //==============================================================================
125 void reset() noexcept;
126
128 void clearChannel (int channel) noexcept;
129
131 void clearSource (uint32 mpeSourceID);
132
133private:
134 MPEZoneLayout::Zone zone;
135
136 int channelIncrement;
137 int firstChannel, lastChannel;
138
139 uint32 sourceAndChannel[17];
140 uint32 lastUsed[17];
141 uint32 counter = 0;
142
143 //==============================================================================
144 bool applyRemapIfExisting (int channel, uint32 sourceAndChannelID, MidiMessage& m) noexcept;
145 int getBestChanToReuse() const noexcept;
146
147 void zeroArrays();
148
149 //==============================================================================
150 bool messageIsNoteData (const MidiMessage& m) { return (*m.getRawData() & 0xf0) != 0xf0; }
151};
152
153} // namespace juce
bool isEmpty() const noexcept
Definition juce_Array.h:222
int findMidiChannelForNewNote(int noteNumber) noexcept
void noteOff(int noteNumber, int midiChannel=-1)
void remapMidiChannelIfNeeded(MidiMessage &message, uint32 mpeSourceID) noexcept
static const uint32 notMPE
void clearChannel(int channel) noexcept
void clearSource(uint32 mpeSourceID)