void onClosed(object sender, FormClosedEventArgs e) { mahPort.shutdown(); pthrough.Join(); DeregisterOurDevice(); lock (inLock) { if (inPort.IsOpen) { inPort.Stop(); inPort.Close(); } } lock (outLock) { if (outPort.IsOpen) { outPort.Close(); } } trayIcon.Icon = null; trayIcon.Dispose(); if (config_changed == true) { config.Save(ConfigurationSaveMode.Full); } }
public void Close() { if (_outPort.IsOpen) { _outPort.Close(); } }
public void Start(int inPortId, int outPortId, MidiNoteMapIndex index) { _index = index; try { byte channel = (byte)((InChannel - 1) & 0x0F); _inNoteOn = (byte)(NoteOn | channel); _inNoteOff = (byte)(NoteOff | channel); channel = (byte)((OutChannel - 1) & 0x0F); _outNoteOn = (byte)(NoteOn | channel); _outNoteOff = (byte)(NoteOff | channel); _diagnosticsReceiver.Reset(); _outPort.Open(outPortId); _inPort.Open(inPortId); _inPort.Start(); } catch { if (_outPort.HasStatus(MidiPortStatus.Open)) { _outPort.Close(); } if (_inPort.HasStatus(MidiPortStatus.Open)) { _inPort.Close(); } throw; } sendTest(); }