public APCMiniController(InputDevice inputDevice, OutputDevice outputDevice, OutputDevice outputDevice2) { _inputDevice = inputDevice; _outputDevice = outputDevice; _outputDevice2 = outputDevice2; _channelStopper = new ChannelStopper(); _inputDevice.ChannelMessageReceived += InputDeviceOnChannelMessageReceived; for (int i = 1; i < 10; i++) { Controls.Add(new Fader("Fader " + i, i + 47, this)); } for (int i = 1; i < 65; i++) { Controls.Add(new MatrixButton("Bouton " + i, i - 1, this)); } for (int i = 1; i < 9; i++) { Controls.Add(new BottomButton("Bottom " + i, i + 63, this)); } for (int i = 1; i < 9; i++) { Controls.Add(new RightButton("Right " + i, i + 81, this)); } Controls.Add(new ShiftButton("Shift", 98, this)); _inputDevice.StartRecording(); }
private void ConnectDevice() { if (isConnected == false) { isConnected = true; // Connect to input midi device based on index inDevice = new InputDevice(MidiDeviceIndex); ChannelStopper stopper = new ChannelStopper(); MidiLogBox.Items.Add("Connected to MIDI input device " + InputDevice.GetDeviceCapabilities(MidiDeviceIndex).name); MidiLogBox.Items.Add("Driver Version: " + InputDevice.GetDeviceCapabilities(MidiDeviceIndex).driverVersion); MidiLogBox.Items.Add("Manufacturer ID: " + InputDevice.GetDeviceCapabilities(MidiDeviceIndex).mid); inDevice.ChannelMessageReceived += delegate(object midiSender, ChannelMessageEventArgs eMidi) { if (midiChannels.Contains(eMidi.Message.MidiChannel + 1)) { // log midi messages stopper.Process(eMidi.Message); MidiLogBox.Items.Add("Ch:" + (eMidi.Message.MidiChannel + 1) + " Cmd:" + eMidi.Message.Command + " D1:" + eMidi.Message.Data1 + " D2:" + eMidi.Message.Data2); MidiLogBox.SelectedIndex = MidiLogBox.Items.Count - 1; MidiLogBox.SelectedIndex = -1; } }; // Show that we're connected now! inDevice.StartRecording(); MidiConnectBtn.Text = "Disconnect"; } else { isConnected = false; // Switch the button back to "Connect" and close our previous midi connection MidiConnectBtn.Text = "Connect"; inDevice.Close(); } }