private void MidiInputDropdown_SelectedIndexChanged(object sender, EventArgs e) { var selectedInput = midiInputDropdown.SelectedItem.ToString(); StopMidi(); foreach (var inputDevice in MidiDeviceManager.Default.InputDevices) { if (inputDevice.Name == selectedInput) { midiInputDevice = inputDevice.CreateDevice(); midiInputDevice.NoteOn += MidiInputDeviceOnNoteOn; midiInputDevice.NoteOff += MidiInputDeviceOnNoteOff; midiInputDevice.Open(); } } }
protected override Task OnInitialize(MidiDeviceConfiguration configuration, CancellationToken cancellationToken) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } // Attach input device if (!string.IsNullOrEmpty(configuration.InputDeviceName)) { var inputDeviceInfo = MidiDeviceManager.Default.InputDevices.FirstOrDefault(d => d.Name.StartsWith(configuration.InputDeviceName)); if (inputDeviceInfo != null) { _inputDevice = inputDeviceInfo.CreateDevice(); _inputDevice.NoteOn += DeviceOnNoteOn; _inputDevice.NoteOff += DeviceOnNoteOff; _inputDevice.ControlChange += DeviceOnControlChange; _inputDevice.ChannelPressure += InputDeviceOnChannelPressure; _inputDevice.PitchBend += InputDeviceOnPitchBend; _inputDevice.ProgramChange += InputDeviceOnProgramChange; _inputDevice.PolyphonicKeyPressure += InputDeviceOnPolyphonicKeyPressure; _inputDevice.Nrpn += InputDeviceOnNrpn; _inputDevice.SysEx += InputDeviceOnSysEx; } } // Attach output device if (!string.IsNullOrEmpty(configuration.OutputDeviceName)) { var outputDeviceInfo = MidiDeviceManager.Default.OutputDevices.FirstOrDefault(d => d.Name.StartsWith(configuration.OutputDeviceName)); if (outputDeviceInfo != null) { _outputDevice = outputDeviceInfo.CreateDevice(); } } return(Task.CompletedTask); }
public void Init() { var slIn = MidiDeviceManager.Default.InputDevices.SingleOrDefault(i => i.Name == "SL GRAND "); var slOut = MidiDeviceManager.Default.OutputDevices.SingleOrDefault(i => i.Name == "kipy_loopback1 "); if (slIn != null) { _inputDevice = slIn.CreateDevice(); _inputDevice.ControlChange += InputDevice_ControlChange; _inputDevice.NoteOn += InputDevice_NoteOn; _inputDevice.NoteOff += _inputDevice_NoteOff; _inputDevice.Nrpn += _inputDevice_Nrpn; _inputDevice.ChannelPressure += _inputDevice_ChannelPressure; _inputDevice.PitchBend += _inputDevice_PitchBend; _inputDevice.PolyphonicKeyPressure += _inputDevice_PolyphonicKeyPressure; _inputDevice.ProgramChange += _inputDevice_ProgramChange; _inputDevice.Open(); _outputDevice = slOut.CreateDevice(); _outputDevice.Open(); } }
protected override Task OnInitialize(DeviceConfiguration configuration, CancellationToken cancellationToken) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var x = MidiDeviceManager.Default.InputDevices.ToArray(); var deviceInfo = MidiDeviceManager.Default.InputDevices.FirstOrDefault(d => d.Name.StartsWith(configuration.DeviceName)); if (deviceInfo == null) { throw new ArgumentException("configured device is not available", nameof(configuration)); } _device = deviceInfo.CreateDevice(); _device.NoteOn += DeviceOnNoteOn; _device.NoteOff += DeviceOnNoteOff; _device.ControlChange += DeviceOnControlChange; return(Task.CompletedTask); }
private void MidiInputDeviceOnNoteOff(IMidiInputDevice sender, in NoteOffMessage msg)
private void _inputDevice_ProgramChange(IMidiInputDevice sender, in ProgramChangeMessage msg)
private void DeviceOnControlChange(IMidiInputDevice sender, in ControlChangeMessage msg)
private void InputDeviceOnSysEx(IMidiInputDevice sender, in SysExMessage msg)
/// <summary> /// ノート・オフ (0x8n) /// </summary> /// <param name="sender"></param> /// <param name="msg"></param> private void NoteOffMessageHandler(IMidiInputDevice sender, in NoteOffMessage msg)
public void ControlChangeHandler(IMidiInputDevice sender, in NoteOnMessage msg)