OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_MPEUtils.h
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
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
69 int findMidiChannelForExistingNote (int initialNoteOnNumber) noexcept;
70
77 void noteOff (int noteNumber, int midiChannel = -1);
78
80 void allNotesOff();
81
82 private:
83 bool isLegacy = false;
84 std::unique_ptr<MPEZoneLayout::Zone> zone;
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//==============================================================================
107 class MPEChannelRemapper
108{
109 public:
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
136 void clearSource (uint32 mpeSourceID);
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
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::findMidiChannelForExistingNote
int findMidiChannelForExistingNote(int initialNoteOnNumber) noexcept
Definition juce_MPEUtils.cpp:87
juce::MPEChannelAssigner::MPEChannelAssigner
MPEChannelAssigner(MPEZoneLayout::Zone zoneToUse)
Definition juce_MPEUtils.cpp:26
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:97
juce::MPEChannelAssigner::allNotesOff
void allNotesOff()
Definition juce_MPEUtils.cpp:123
juce::MPEChannelRemapper
Definition juce_MPEUtils.h:108
juce::MPEChannelRemapper::reset
void reset() noexcept
Definition juce_MPEUtils.cpp:213
juce::MPEChannelRemapper::remapMidiChannelIfNeeded
void remapMidiChannelIfNeeded(MidiMessage &message, uint32 mpeSourceID) noexcept
Definition juce_MPEUtils.cpp:168
juce::MPEChannelRemapper::notMPE
static const uint32 notMPE
Definition juce_MPEUtils.h:111
juce::MPEChannelRemapper::clearChannel
void clearChannel(int channel) noexcept
Definition juce_MPEUtils.cpp:219
juce::MPEChannelRemapper::clearSource
void clearSource(uint32 mpeSourceID)
Definition juce_MPEUtils.cpp:224
juce::MPEChannelRemapper::MPEChannelRemapper
MPEChannelRemapper(MPEZoneLayout::Zone zoneToRemap)
Definition juce_MPEUtils.cpp:157
juce::MPEZoneLayout
Definition juce_MPEZoneLayout.h:123
juce::MidiMessage
Definition juce_MidiMessage.h:35
juce::Range
Definition juce_Range.h:40
juce::MPEZone
Definition juce_MPEZoneLayout.h:42