private void sendSustainPedalUpToAllDeviceChannelsWithSustainPedalDown(DeviceBase damperMsgSourceDevice) { // The idea being that lifting the sustain pedal un-sustains every soundGenerator previously for (int i = mappedMidiControls.Count - 1; i >= 0; --i) { MappedMidiControl ctl = mappedMidiControls[i]; if (ctl.sourceDeviceName == damperMsgSourceDevice.Name && ctl.mappedControl == Midi.Control.SustainPedal) { ctl.mappedDevice.SendControlChange(ctl.mappedChannel, Midi.Control.SustainPedal, 0); mappedMidiControls.Remove(ctl); } } }
private void recordSustainPedalDown(DeviceBase damperMsgSourceDevice, OutputDevice physicalDeviceWithDamperDown, Channel physicalChannelWithDamperDown) { // Create a control mapping entry for this damper-down MappedMidiControl mappedControl = new MappedMidiControl(); mappedControl.sourceDeviceName = damperMsgSourceDevice.Name; mappedControl.mappedDevice = physicalDeviceWithDamperDown; mappedControl.mappedChannel = physicalChannelWithDamperDown; mappedControl.mappedControl = Midi.Control.SustainPedal; // Damper mappedControl.mappedValue = 127; // If, for some reason, there's an existing mapping of this control in the list delete it. for (int i = mappedMidiControls.Count - 1; i >= 0; --i) { MappedMidiControl ctl = mappedMidiControls[i]; if (ctl.sourceDeviceName == damperMsgSourceDevice.Name && ctl.mappedDevice == physicalDeviceWithDamperDown && ctl.mappedChannel == physicalChannelWithDamperDown && ctl.mappedControl == Midi.Control.SustainPedal) { mappedMidiControls.Remove(ctl); } } // Add the newly created control to the list mappedMidiControls.Add(mappedControl); }