Esempio n. 1
0
        private async void MidiDeviceSelected(object sender, SelectionChangedEventArgs e)
        {
            var selectedDevice = (MidiDeviceInfo)OutputDevicesList.SelectedItem;

            if (selectedDevice != null)
            {
                _currentDevice?.Dispose();
                _currentDevice = await MidiOutPort.FromIdAsync(selectedDevice.Id);

                KeyboardKeys.IsEnabled = true;
            }
        }
Esempio n. 2
0
        // Called when app is suspending
        private void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
        {
            // Clean up out watchers
            inputDeviceWatcher.StopWatcher();
            inputDeviceWatcher = null;

            outputDeviceWatcher.StopWatcher();
            outputDeviceWatcher = null;

            // Remove EventHandlers and try dispose of input & output ports
            try
            {
                midiInPort.MessageReceived -= MidiInPort_MessageReceived;
                midiInPort.Dispose();
                midiInPort = null;
            }
            catch
            {
            }

            try
            {
                midiOutPort.Dispose();
                midiOutPort = null;
            }
            catch
            {
            }
        }
Esempio n. 3
0
        public static uint midiOutClose(IntPtr hmo)
        {
            if (s_midiOutPort != null)
            {
                s_midiOutPort.Dispose();
            }

            s_midiOutPort = null;

            return(MidiWinApi.MMSYSERR_NOERROR);
        }
Esempio n. 4
0
 public void ResetMidiOutput()
 {
     try
     {
         if (midiOutPort != null)
         {
             midiOutPort.Dispose();
             midiOutPort = null;
             GC.Collect();
         }
     }
     catch { }
 }
Esempio n. 5
0
        public void TeardownWatchers()
        {
            inputDeviceWatcher.StopWatcher();
            inputDeviceWatcher = null;

            outputDeviceWatcher.StopWatcher();
            outputDeviceWatcher = null;

            midiInPort.MessageReceived -= MidiInPort_MessageReceived;
            midiInPort.Dispose();
            midiInPort = null;

            midiOutPort.Dispose();
            midiOutPort = null;
        }
Esempio n. 6
0
        /// <summary>
        /// Eventhandler to clean up the MIDI connection, when the app is suspended.
        /// The object midiOutPort is disposed and set to null
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void App_Suspending(object sender, SuspendingEventArgs e)
        {
            try
            {
                // Dispose the Midi Output port
                midiOutPort.Dispose();

                // Set the midiOutPort to null
                midiOutPort = null;
            }
            catch
            {
                // Do noting. A cleanup has already been made
            }
        }
Esempio n. 7
0
        private void CleanUp()
        {
            // <SnippetCleanUp>
            inputDeviceWatcher.StopWatcher();
            inputDeviceWatcher = null;

            outputDeviceWatcher.StopWatcher();
            outputDeviceWatcher = null;

            midiInPort.MessageReceived -= MidiInPort_MessageReceived;
            midiInPort.Dispose();
            midiInPort = null;

            midiOutPort.Dispose();
            midiOutPort = null;
            // </SnippetCleanUp>
        }
Esempio n. 8
0
 public void Close()
 {
     port.Dispose();
 }