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
23 namespace juce
24{
25
26//==============================================================================
37 class MPEChannelAssigner
38{
39 public:
44 MPEChannelAssigner (MPEZoneLayout::Zone zoneToUse);
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
77 private:
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//==============================================================================
102 class MPEChannelRemapper
103{
104 public:
106 static const uint32 notMPE = 0;
107
109 MPEChannelRemapper (MPEZoneLayout::Zone zoneToRemap);
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
juce::Array
Definition: juce_Array.h:56
juce::Array::isEmpty
bool isEmpty() const noexcept
Definition: juce_Array.h:222
juce::MPEChannelAssigner
Definition: juce_MPEUtils.h:38
juce::MPEChannelAssigner::findMidiChannelForNewNote
int findMidiChannelForNewNote(int noteNumber) noexcept
Definition: juce_MPEUtils.cpp:50
juce::MPEChannelAssigner::noteOff
void noteOff(int noteNumber, int midiChannel=-1)
Definition: juce_MPEUtils.cpp:87
juce::MPEChannelAssigner::allNotesOff
void allNotesOff()
Definition: juce_MPEUtils.cpp:113
juce::MPEChannelRemapper
Definition: juce_MPEUtils.h:103
juce::MPEChannelRemapper::reset
void reset() noexcept
Definition: juce_MPEUtils.cpp:203
juce::MPEChannelRemapper::remapMidiChannelIfNeeded
void remapMidiChannelIfNeeded(MidiMessage &message, uint32 mpeSourceID) noexcept
Definition: juce_MPEUtils.cpp:158
juce::MPEChannelRemapper::notMPE
static const uint32 notMPE
Definition: juce_MPEUtils.h:106
juce::MPEChannelRemapper::clearChannel
void clearChannel(int channel) noexcept
Definition: juce_MPEUtils.cpp:209
juce::MPEChannelRemapper::clearSource
void clearSource(uint32 mpeSourceID)
Definition: juce_MPEUtils.cpp:214
juce::MPEZoneLayout
Definition: juce_MPEZoneLayout.h:45
juce::MidiMessage
Definition: juce_MidiMessage.h:35
juce::Range
Definition: juce_Range.h:40
juce::MPEZoneLayout::Zone
Definition: juce_MPEZoneLayout.h:82