93 if (lowerZone.isActive())
95 lowerZone.perNotePitchbendRange,
96 lowerZone.masterPitchbendRange),
100 if (upperZone.isActive())
102 upperZone.perNotePitchbendRange,
103 upperZone.masterPitchbendRange),
114 class MPEMessagesTests :
public UnitTest 118 :
UnitTest (
"MPEMessages class", UnitTestCategories::midi)
121 void runTest()
override 123 beginTest (
"add zone");
128 const uint8 expectedBytes[] =
130 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x07,
131 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x30,
132 0xb0, 0x64, 0x00, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x02
135 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
140 const uint8 expectedBytes[] =
142 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x05,
143 0xbe, 0x64, 0x00, 0xbe, 0x65, 0x00, 0xbe, 0x06, 0x60,
144 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00
147 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
151 beginTest (
"set per-note pitchbend range");
155 const uint8 expectedBytes[] = { 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x60 };
157 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
161 beginTest (
"set master pitchbend range");
165 const uint8 expectedBytes[] = { 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x3c };
167 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
170 beginTest (
"clear all zones");
174 const uint8 expectedBytes[] = { 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
175 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00
178 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
181 beginTest (
"set complete state");
190 const uint8 expectedBytes[] = {
191 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
192 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00,
193 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x07,
194 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x60,
195 0xb0, 0x64, 0x00, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
196 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x07,
197 0xbe, 0x64, 0x00, 0xbe, 0x65, 0x00, 0xbe, 0x06, 0x30,
198 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x02
201 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
207 void testMidiBuffer (
MidiBuffer& buffer,
const uint8* expectedBytes,
int expectedBytesSize)
209 uint8 actualBytes[128] = { 0 };
210 extractRawBinaryData (buffer, actualBytes,
sizeof (actualBytes));
212 expectEquals (std::memcmp (actualBytes, expectedBytes, (std::size_t) expectedBytesSize), 0);
216 void extractRawBinaryData (
const MidiBuffer& midiBuffer,
const uint8* bufferToCopyTo, std::size_t maxBytes)
226 std::size_t dataSize = (std::size_t) midiMessage.
getRawDataSize();
228 if (pos + dataSize > maxBytes)
231 std::memcpy ((
void*) (bufferToCopyTo + pos), data, dataSize);
237 static MPEMessagesTests MPEMessagesUnitTests;
This class represents the current MPE zone layout of a device capable of handling MPE...
Encapsulates a MIDI message.
static MidiBuffer generate(MidiRPNMessage message)
Generates a MIDI sequence representing the given RPN or NRPN message.
bool getNextEvent(MidiMessage &result, int &samplePosition) noexcept
Retrieves a copy of the next event from the buffer.
static MidiBuffer setUpperZonePerNotePitchbendRange(int perNotePitchbendRange=48)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the per-no...
int getRawDataSize() const noexcept
Returns the number of bytes of data in the message.
void setUpperZone(int numMemberChannels=0, int perNotePitchbendRange=48, int masterPitchbendRange=2) noexcept
Sets the upper zone of this layout.
static MidiBuffer setUpperZone(int numMemberChannels=0, int perNotePitchbendRange=48, int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the upper ...
static MidiBuffer setLowerZone(int numMemberChannels=0, int perNotePitchbendRange=48, int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the lower ...
const Zone getUpperZone() const noexcept
Returns a struct representing the upper MPE zone.
static MidiBuffer clearAllZones()
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will clear the lowe...
This is a base class for classes that perform a unit test.
const Zone getLowerZone() const noexcept
Returns a struct representing the lower MPE zone.
static MidiBuffer setLowerZonePerNotePitchbendRange(int perNotePitchbendRange=48)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the per-no...
static MidiBuffer clearUpperZone()
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will clear the uppe...
static MidiBuffer clearLowerZone()
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will clear the lowe...
static MidiBuffer setLowerZoneMasterPitchbendRange(int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the master...
Holds a sequence of time-stamped midi events.
const uint8 * getRawData() const noexcept
Returns a pointer to the raw midi data.
static MidiBuffer setZoneLayout(MPEZoneLayout layout)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will reset the whol...
static MidiBuffer setUpperZoneMasterPitchbendRange(int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the master...
Used to iterate through the events in a MidiBuffer.
void addEvents(const MidiBuffer &otherBuffer, int startSample, int numSamples, int sampleDeltaToAdd)
Adds some events from another buffer to this one.
static const int zoneLayoutMessagesRpnNumber
The RPN number used for MPE zone layout messages.
void setLowerZone(int numMemberChannels=0, int perNotePitchbendRange=48, int masterPitchbendRange=2) noexcept
Sets the lower zone of this layout.