Loading...
Searching...
No Matches
juce_MPEUtils.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class MPEChannelAssigner
{
public:
MPEChannelAssigner (MPEZoneLayout::Zone zoneToUse);
MPEChannelAssigner (Range<int> channelRange = Range<int> (1, 17));
int findMidiChannelForNewNote (int noteNumber) noexcept;
int findMidiChannelForExistingNote (int initialNoteOnNumber) noexcept;
void noteOff (int noteNumber, int midiChannel = -1);
void allNotesOff();
private:
bool isLegacy = false;
std::unique_ptr<MPEZoneLayout::Zone> zone;
int channelIncrement, numChannels, firstChannel, lastChannel, midiChannelLastAssigned;
//==============================================================================
struct MidiChannel
{
Array<int> notes;
int lastNotePlayed = -1;
bool isFree() const noexcept { return notes.isEmpty(); }
};
std::array<MidiChannel, 17> midiChannels;
//==============================================================================
int findMidiChannelPlayingClosestNonequalNote (int noteNumber) noexcept;
};
//==============================================================================
class MPEChannelRemapper
{
public:
static const uint32 notMPE = 0;
MPEChannelRemapper (MPEZoneLayout::Zone zoneToRemap);
//==============================================================================
void remapMidiChannelIfNeeded (MidiMessage& message, uint32 mpeSourceID) noexcept;
//==============================================================================
void reset() noexcept;
void clearChannel (int channel) noexcept;
void clearSource (uint32 mpeSourceID);
private:
MPEZoneLayout::Zone zone;
int channelIncrement;
int firstChannel, lastChannel;
uint32 sourceAndChannel[17];
uint32 lastUsed[17];
uint32 counter = 0;
//==============================================================================
bool applyRemapIfExisting (int channel, uint32 sourceAndChannelID, MidiMessage& m) noexcept;
int getBestChanToReuse() const noexcept;
void zeroArrays();
//==============================================================================
bool messageIsNoteData (const MidiMessage& m) { return (*m.getRawData() & 0xf0) != 0xf0; }
};
} // namespace juce
juce::Array
Definition juce_Array.h:56
juce::Array::isEmpty
bool isEmpty() const noexcept
Definition juce_Array.h:222
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::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