93 if (lowerZone.isActive())
95 lowerZone.perNotePitchbendRange,
96 lowerZone.masterPitchbendRange),
100 if (upperZone.isActive())
102 upperZone.perNotePitchbendRange,
103 upperZone.masterPitchbendRange),
113 class MPEMessagesTests :
public UnitTest
116 MPEMessagesTests() :
UnitTest (
"MPEMessages class",
"MIDI/MPE") {}
118 void runTest()
override
120 beginTest (
"add zone");
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));
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");
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");
162 const uint8 expectedBytes[] = { 0xbf, 0x64, 0x00, 0xbf, 0x65, 0x00, 0xbf, 0x06, 0x3c };
164 testMidiBuffer (buffer, expectedBytes,
sizeof (expectedBytes));
167 beginTest (
"clear all zones");
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);
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);
234 static MPEMessagesTests MPEMessagesUnitTests;
236 #endif // JUCE_UNIT_TESTS