private void ShowImage() { var colors = _image.GetPixels(); for (int i = 0; i < colors.Length; i++) { var msg = CreateLEDMessage((byte)i, colors[i], false); _midiOutput.Send(msg); } }
public static void Sample() { // List all available MIDI API's foreach (var api in MidiDeviceManager.Default.GetAvailableMidiApis()) { Console.WriteLine($"Available API: {api}"); } // Listen to all available midi devices void ControlChangeHandler(IMidiInputDevice sender, in ControlChangeMessage msg) { Console.WriteLine($"[{sender.Name}] ControlChange: Channel:{msg.Channel} Control:{msg.Control} Value:{msg.Value}"); } var devices = new List <IMidiDevice>(); try { IMidiOutputDevice output = null; foreach (var inputDeviceInfo in MidiDeviceManager.Default.InputDevices) { Console.WriteLine($"Opening {inputDeviceInfo.Name}"); var inputDevice = inputDeviceInfo.CreateDevice(); devices.Add(inputDevice); inputDevice.ControlChange += ControlChangeHandler; inputDevice.NoteOn += (IMidiInputDevice sender, in NoteOnMessage msg) => { Console.WriteLine(msg); output?.Send(msg); }; inputDevice.NoteOff += (IMidiInputDevice sender, in NoteOffMessage msg) => { Console.WriteLine(msg); output?.Send(msg); }; inputDevice.PolyphonicKeyPressure += (IMidiInputDevice sender, in PolyphonicKeyPressureMessage msg) => Console.WriteLine("PolyphonicKeyPressure"); inputDevice.Open(); } foreach (var outputDeviceInfo in MidiDeviceManager.Default.OutputDevices) { Console.WriteLine($"Opening output: {outputDeviceInfo.Name}"); var outputDevice = outputDeviceInfo.CreateDevice(); devices.Add(outputDevice); outputDevice.Open(); output = outputDevice; break; } Console.WriteLine("Press any key to stop..."); Console.ReadKey(); } finally { foreach (var device in devices) { device.Dispose(); } } }
public void Button1_HandPointerEnter(object sender, System.EventArgs e) { txtMessage.Text = ((KinectV2CustomButton)sender).Name; txtMessage.FontSize = 1; buttonoff = true; var brush = new ImageBrush(); var brush2 = new ImageBrush(); brush.ImageSource = new BitmapImage(new Uri(@"C:\Users\markk\Desktop\my_kinect_violin\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\Images\violinicon.png", UriKind.Relative)); brush2.ImageSource = new BitmapImage(new Uri(@"C:\Users\markk\Desktop\my_kinect_violin\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\WPFKinectV2CustomButton-master\Images\violinicon2.png", UriKind.Relative)); //GestureResultView ob = new GestureResultView(0, false, false, 0, false); //ob.UpdateGestureResult.; textBlock.Text = continueplaying.ToString(); textBlock.FontSize = 1; if (playing == true) { if (txtMessage.Text == "E0" && GestureResultView.detect == true) { //if ( == true) ((KinectV2CustomButton)sender).Background = brush2; //else // ((KinectV2CustomButton)sender).Background = brush; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key76 + chord, 127)); //this.ImageSource = this.seatedImage; //playing = true; } else if (txtMessage.Text == "E1" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key78 + chord, 127)); //playing = true; } else if (txtMessage.Text == "E2" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key80 + chord, 127)); //playing = true; } else if (txtMessage.Text == "E3" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key81 + chord, 127)); //playing = true; } else if (txtMessage.Text == "A0" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key69 + chord, 127)); //playing = true; } else if (txtMessage.Text == "A1" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key71 + chord, 127)); //playing = true; } else if (txtMessage.Text == "A2" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key72 + chord, 127)); //playing = true; } else if (txtMessage.Text == "A3" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key74 + chord, 127)); //playing = true; } else if (txtMessage.Text == "D0" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key62 + chord, 127)); //playing = true; } else if (txtMessage.Text == "D1" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key64 + chord, 127)); //playing = true; } else if (txtMessage.Text == "D2" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key66 + chord, 127)); //playing = true; } else if (txtMessage.Text == "D3" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key67 + chord, 127)); //playing = true; } else if (txtMessage.Text == "G0" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key55 + chord, 127)); //playing = true; } else if (txtMessage.Text == "G1" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key57 + chord, 127)); //playing = true; } else if (txtMessage.Text == "G2" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key59 + chord, 127)); //playing = true; } else if (txtMessage.Text == "G3" && GestureResultView.detect == true) { ((KinectV2CustomButton)sender).Background = brush2; dev.Send(new ProgramChangeMessage(Channel.Channel1, a)); dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key60 + chord, 127)); //playing = true; } if (txtMessage.Text == "Ensem") { //KinectButtons2 ((KinectV2CustomButton)sender).Background = brush2; //buttonoff = true; a = 49; chord = 0; //dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key60, 127)); //playing = true; } else if (txtMessage.Text == "Violin") { ((KinectV2CustomButton)sender).Background = brush2; a = 40; chord = 0; //dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key60, 127)); //playing = true; } else if (txtMessage.Text == "Cello") { ((KinectV2CustomButton)sender).Background = brush2; a = 42; chord = -20; //dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key60, 127)); //playing = true; } else if (txtMessage.Text == "Bass") { ((KinectV2CustomButton)sender).Background = brush2; a = 43; chord = -32; //dev.Send(new NoteOnMessage(Channel.Channel1, Key.Key60, 127)); //playing = true; } } ButtonName = txtMessage.Text; send = sender; }