Exemple #1
0
        private void InputWatcher_Added(DeviceWatcher sender, DeviceInformation args)
        {
            var id = args.Id;

            // you could use DeviceInformation directly here, using the
            // CreateFromIdAsync method. However, that is an async method
            // and so adds a bit of delay. I'm using a trimmed down object
            // to hold MIDI information rather than using the DeviceInformation class

#if DEBUG
            // this is so you can see what the properties contain
            //foreach (var p in args.Properties.Keys)
            //{
            //    System.Diagnostics.Debug.WriteLine("Input: " + args.Name + " : " + p + " : " + args.Properties[p]);
            //}
#endif

            var info = new MidiDeviceInformation();
            info.Id        = id;
            info.Name      = args.Name;
            info.IsDefault = args.IsDefault;
            info.IsEnabled = args.IsEnabled;

            ConnectedInputDevices.Add(info);

            // notify clients
            if (InputDevicesChanged != null)
            {
                InputDevicesChanged(this, new EventArgs());
            }
        }
Exemple #2
0
 /// <summary>
 /// sets the output device to send midi messages to
 /// </summary>
 /// <param name="devInfo">device to connect to</param>
 public async void connectToOutputDevice(MidiDeviceInformation devInfo)
 {
     midiOut = (MidiOutPort)await MidiOutPort.FromIdAsync(devInfo.Id);
 }
Exemple #3
0
        /// <summary>
        /// sets the input device to receive midi messages from
        /// </summary>
        /// <param name="devInfo">device to use</param>
        public async void connectToInputDevice(MidiDeviceInformation devInfo)
        {
            midiIn = await MidiInPort.FromIdAsync(devInfo.Id);

            midiIn.MessageReceived += MidiInputDevice_MessageReceived;
        }