// Called when the window loads. private void Form1_Load(object sender, EventArgs e) { // Set up a clock for scheduling output events. clock = new Clock(140); // Create persistent delegates which we can add and remove to events. noteOnHandler = new InputDevice.NoteOnHandler(this.NoteOn); noteOffHandler = new InputDevice.NoteOffHandler(this.NoteOff); // Populate the list box with input devices, preferring the one from the previous // session if any. InputDevice preferredInputDevice = InputDevice.DeviceWithSpec(Properties.Settings.Default.MidiInputDeviceSpec); foreach (InputDevice device in InputDevice.InstalledDevices) { int idx = inputListBox.Items.Add(device.Spec); if (device == preferredInputDevice) { UseInputDevice(device); inputListBox.SelectedIndex = idx; } } // Populate the list box with output devices, preferring the one from the previous // session if any. OutputDevice preferredOutputDevice = OutputDevice.DeviceWithSpec(Properties.Settings.Default.MidiOutputDeviceSpec); foreach (OutputDevice device in OutputDevice.InstalledDevices) { int idx = outputListBox.Items.Add(device.Spec); if (device == preferredOutputDevice) { UseOutputDevice(device); outputListBox.SelectedIndex = idx; } } }