public SettingsPage() { this.InitializeComponent(); inputDeviceWatcher = new MidiDeviceWatcher(MidiInPort.GetDeviceSelector(), midiInPortListBox, Dispatcher); inputDeviceWatcher.StartWatcher(); outputDeviceWatcher = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), midiOutPortListBox, Dispatcher); outputDeviceWatcher.StartWatcher(); //Set the slider back to the values the user put in velocitySlider.Value = (Settings.velocity - 27); volumeSlider.Value = (Settings.volume + 50); if (Settings.feedback == true) { volumeSlider.IsEnabled = true; velocitySlider.IsEnabled = false; } else { Feedback.IsChecked = true; volumeSlider.IsEnabled = false; velocitySlider.IsEnabled = true; } }
// All output ports have been enumerated private async void _watcher_OutputPortsEnumerated(MidiDeviceWatcher sender) { foreach (DeviceInformation info in sender.OutputPortDescriptors) { // This diagnostic info is how you can see the IDs of all the ports. System.Diagnostics.Debug.WriteLine("- Output -----"); System.Diagnostics.Debug.WriteLine(info.Name); System.Diagnostics.Debug.WriteLine(info.Id); System.Diagnostics.Debug.WriteLine("--------------"); var port = (MidiOutPort)await MidiOutPort.FromIdAsync(info.Id); // If you don't want the clock on all ports, here's where you'd change the code if (port != null) { _clock.OutputPorts.Add(port); } else { System.Diagnostics.Debug.WriteLine("Failed to create port with id " + info.Id); } } if (_clock.OutputPorts.Count > 0) { System.Diagnostics.Debug.WriteLine("About to create clock."); _clock.SendMidiStartMessage = true; _clock.SendMidiStopMessage = true; } else { System.Diagnostics.Debug.WriteLine("No output ports to wire up."); } }
public MainPage() { this.InitializeComponent(); _watcher = new MidiDeviceWatcher(); _clock = new MidiClockGenerator(); Loaded += MainPage_Loaded; }
// All input ports have been enumerated private void _watcher_InputPortsEnumerated(MidiDeviceWatcher sender) { foreach (DeviceInformation info in sender.InputPortDescriptors) { System.Diagnostics.Debug.WriteLine("- Input -----"); System.Diagnostics.Debug.WriteLine(info.Name); System.Diagnostics.Debug.WriteLine(info.Id); System.Diagnostics.Debug.WriteLine("--------------"); } }
public MidiPage() { this.InitializeComponent(); // Set up the MIDI output device watcher _midiOutDeviceWatcher = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), Dispatcher, OutputDevicesList, OutputDevices); OutputDevicesList.ItemsSource = OutputDevices; // Start watching for devices _midiOutDeviceWatcher.Start(); Unloaded += MidiDeviceOutputTests_Unloaded; }
private void InitializeMidi() { _midiClock = new MidiClockGenerator(); _midiWatcher = new MidiDeviceWatcher(); _midiClock.SendMidiStartMessage = true; _midiClock.SendMidiStopMessage = true; _midiClock.Tempo = 84; _midiWatcher.IgnoreBuiltInWavetableSynth = true; _midiWatcher.EnumerateOutputPorts(); }
// All input ports have been enumerated private void _watcher_InputPortsEnumerated(MidiDeviceWatcher sender) { foreach (var info in sender.InputPortDescriptors) { System.Diagnostics.Debug.WriteLine("- Input -----"); System.Diagnostics.Debug.WriteLine("- Name: " + info.Name); System.Diagnostics.Debug.WriteLine("- Id: " + info.Id); System.Diagnostics.Debug.WriteLine("- Kind: " + info.DeviceInformation.Kind); System.Diagnostics.Debug.WriteLine("- InterfaceType: " + info.InterfaceType); DebugDisplayDeviceInformationProperties(info.DeviceInformation); System.Diagnostics.Debug.WriteLine("--------------"); } }
/// <summary> /// Constructor: Start the device watcher /// </summary> public MidiDeviceInput() { InitializeComponent(); rootGrid.DataContext = this; // Initialize the list of active MIDI input devices _midiInPorts = new List <MidiInPort>(); // Set up the MIDI input device watcher _midiInDeviceWatcher = new MidiDeviceWatcher(MidiInPort.GetDeviceSelector(), Dispatcher, inputDevices, InputDevices); // Start watching for devices _midiInDeviceWatcher.Start(); Unloaded += MidiDeviceInput_Unloaded; }
public MainPage() { this.InitializeComponent(); App.Current.Suspending += Current_Suspending; mArduino = new ArduinoManager(); mGPIO = new GPIOManager(); mGameNoteIndexs = new int[5] { 0, 0, 0, 0, 0 }; mCurrentGameNote = new MidiGameNote[5]; mIsInited = false; mIsPlaying = false; Task.Run(async() => { SMFReader r = new SMFReader(); mSMF = await r.Read(@"Assets\out.mid"); var w = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), Dispatcher); w.Start(); var col = w.GetDeviceInformationCollection(); var l = await DeviceInformation.FindAllAsync(MidiOutPort.GetDeviceSelector()); MIDIPort = await MidiOutPort.FromIdAsync(l[0].Id); await mArduino.Init(); await mGPIO.Init(GpioController.GetDefault()); mGPIO.MidiButtonChanged += MGPIO_MidiButtonChanged; mGPIO.JoyButtonChanged += MGPIO_JoyButtonChanged; mPlayer = new SMFPlayer(mSMF, MIDIPort); mPlayer.OnLED += Player_OnLED; mPlayer.OnBarBeatChanged += Player_BarBeatChanged; mPlayer.OnTempoChanged += Player_OnTempoChanged; mGPIO.Ack(); mIsInited = true; }); mVolTimer = new DispatcherTimer(); mVolTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); mVolTimer.Tick += MVolTimer_Tick; mVolTimer.Start(); }
private async void OnMidiDevicesEnumerated(MidiDeviceWatcher sender) { var id = _watcher.OutputPortDescriptors.GetAt(0).Id; _activeOutPort = await MidiOutPort.FromIdAsync(id); }