MCPcopy Create free account
hub / github.com/davy7125/polyphone / processControllerChanged

Method processControllerChanged

sources/context/mididevice.cpp:302–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void MidiDevice::processControllerChanged(bool external, int channel, int numController, int value)
303{
304 int initialValue = value;
305 MIDI_State * midiState = &_midiStates[channel + 1];
306 Sustain_State * sustainState = &_sustainStates[channel + 1];
307
308 if (numController == 0 && channel == 9)
309 return; // Ignored: keep bank 128 on channel 10 (percussions)
310
311 if (external)
312 {
313 if (midiState->_controllerValueIsRelative[numController])
314 {
315 // Convert a possible relative value
316 if (value == 126 || value == 62) // -2
317 value = midiState->_controllerValues[numController] - 2;
318 else if (value == 127 || value == 63) // -1
319 value = midiState->_controllerValues[numController] - 1;
320 else if (value == 1 || value == 65) // +1
321 value = midiState->_controllerValues[numController] + 1;
322 else if (value == 2 || value == 66) // +2
323 value = midiState->_controllerValues[numController] + 2;
324 else
325 {
326 // Not a relative value
327 midiState->_controllerValueIsRelative[numController] = false;
328 midiState->_controllerValueIsRelativeCounter[numController] = 0;
329 }
330 }
331 else
332 {
333 // Possibly switch to the relative mode
334 if (value == 127 || value == 126 || value == 63 || value == 62 ||
335 value == 1 || value == 2 || value == 65 || value == 66)
336 {
337 midiState->_controllerValueIsRelativeCounter[numController]++;
338 if (midiState->_controllerValueIsRelativeCounter[numController] > 3)
339 {
340 // Following values will be considered relative
341 midiState->_controllerValueIsRelative[numController] = true;
342 }
343 }
344 else
345 midiState->_controllerValueIsRelativeCounter[numController] = 0;
346 }
347 }
348
349 // Limits
350 if (value < 0)
351 value = 0;
352 if (value > 127)
353 value = 127;
354
355 // Update the current channel
356 midiState->_controllerValues[numController] = value;
357 midiState->_controllerValueSpecified[numController] = true;
358
359 if ((numController >= 96 && numController <= 101) || numController == 6 || numController == 38)

Callers 1

midiCallbackFunction · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected