93 if (lowerZone.isActive())
95 lowerZone.perNotePitchbendRange,
96 lowerZone.masterPitchbendRange),
100 if (upperZone.isActive())
102 upperZone.perNotePitchbendRange,
103 upperZone.masterPitchbendRange),
113class MPEMessagesTests :
public UnitTest
116 MPEMessagesTests() :
UnitTest (
"MPEMessages class",
"MIDI/MPE") {}
118 void runTest()
override
120 beginTest (
"add zone");
123 MidiBuffer buffer = MPEMessages::setLowerZone (7);
125 const uint8 expectedBytes[] =
127 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x07,
128 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x30,
129 0xb0, 0x64, 0x00, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x02
132 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
135 MidiBuffer buffer = MPEMessages::setUpperZone (5, 96, 0);
137 const uint8 expectedBytes[] =
139 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x05,
140 0xbe, 0x64, 0x00, 0xbe, 0x65, 0x00, 0xbe, 0x06, 0x60,
141 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00
144 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
148 beginTest (
"set per-note pitchbend range");
150 MidiBuffer buffer = MPEMessages::setLowerZonePerNotePitchbendRange (96);
152 const uint8 expectedBytes[] = { 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x60 };
154 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
158 beginTest (
"set master pitchbend range");
160 MidiBuffer buffer = MPEMessages::setUpperZoneMasterPitchbendRange (60);
162 const uint8 expectedBytes[] = { 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x3c };
164 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
167 beginTest (
"clear all zones");
169 MidiBuffer buffer = MPEMessages::clearAllZones();
171 const uint8 expectedBytes[] = { 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
172 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00
175 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
178 beginTest (
"set complete state");
180 MPEZoneLayout layout;
182 layout.setLowerZone (7, 96, 0);
183 layout.setUpperZone (7);
185 MidiBuffer buffer = MPEMessages::setZoneLayout (layout);
187 const uint8 expectedBytes[] = {
188 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
189 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x00,
190 0xb0, 0x64, 0x06, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x07,
191 0xb1, 0x64, 0x00, 0xb1, 0x65, 0x00, 0xb1, 0x06, 0x60,
192 0xb0, 0x64, 0x00, 0xb0, 0x65, 0x00, 0xb0, 0x06, 0x00,
193 0xbf, 0x64, 0x06, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x07,
194 0xbe, 0x64, 0x00, 0xbe, 0x65, 0x00, 0xbe, 0x06, 0x30,
195 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x02
198 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
204 void testMidiBuffer (MidiBuffer& buffer,
const uint8* expectedBytes,
int expectedBytesSize)
206 uint8 actualBytes[128] = { 0 };
207 extractRawBinaryData (buffer, actualBytes,
sizeof (actualBytes));
209 expectEquals (std::memcmp (actualBytes, expectedBytes, (std::size_t) expectedBytesSize), 0);
213 void extractRawBinaryData (
const MidiBuffer& midiBuffer,
const uint8* bufferToCopyTo, std::size_t maxBytes)
216 MidiBuffer::Iterator iter (midiBuffer);
217 MidiMessage midiMessage;
220 while (iter.getNextEvent (midiMessage, samplePosition))
222 const uint8* data = midiMessage.getRawData();
223 std::size_t dataSize = (std::size_t) midiMessage.getRawDataSize();
225 if (pos + dataSize > maxBytes)
228 std::memcpy ((
void*) (bufferToCopyTo + pos), data, dataSize);
234static MPEMessagesTests MPEMessagesUnitTests;
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 setUpperZoneMasterPitchbendRange(int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the master...
static MidiBuffer clearAllZones()
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will clear the lowe...
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 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 ...
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 const int zoneLayoutMessagesRpnNumber
The RPN number used for MPE zone layout messages.
static MidiBuffer setLowerZoneMasterPitchbendRange(int masterPitchbendRange=2)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the master...
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 setUpperZonePerNotePitchbendRange(int perNotePitchbendRange=48)
Returns the sequence of MIDI messages that, if sent to an Expressive MIDI device, will set the per-no...
This class represents the current MPE zone layout of a device capable of handling MPE.
const Zone getUpperZone() const noexcept
Returns a struct representing the upper MPE zone.
const Zone getLowerZone() const noexcept
Returns a struct representing the lower MPE zone.
Holds a sequence of time-stamped midi events.
void addEvents(const MidiBuffer &otherBuffer, int startSample, int numSamples, int sampleDeltaToAdd)
Adds some events from another buffer to this one.
static MidiBuffer generate(MidiRPNMessage message)
Generates a MIDI sequence representing the given RPN or NRPN message.
This is a base class for classes that perform a unit test.