MidiBoard/MidiTest/MainWindow.xaml.cs
2020-02-06 14:59:54 +01:00

41 lines
1.2 KiB
C#

using System;
using System.Windows;
using Commons.Music.Midi;
namespace MidiTest {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
this.InitializeComponent();
this.DetectMidi();
}
private void DetectMidi() {
IMidiAccess access = MidiAccessManager.Default;
foreach (IMidiPortDetails item in access.Outputs) {
_ = this.MidiSelector.Items.Add(new Tuple<String, String>(item.Manufacturer + " - " + item.Name, item.Id));
}
}
private void test(Object sender, System.Windows.Input.MouseButtonEventArgs e) {
IMidiOutput outp = MidiAccessManager.Default.OpenOutputAsync(((Tuple<String, String>)this.MidiSelector.SelectedItem).Item2).Result;
outp.Send(new Byte[] { 144, 81, 45 }, 0, 3, 0);
outp.Send(new Byte[] { 176, 106, 53 }, 0, 3, 0);
outp.Send(new Byte[] { 145, 11, 5 }, 0, 3, 0);
outp.Send(new Byte[] { 144, 12, 21 }, 0, 3, 0);
outp.Send(new Byte[] { 145, 12, 5 }, 0, 3, 0);
outp.Send(new Byte[] { 146, 88, 81 }, 0, 3, 0);
}
private void ShowPopup(Object sender, System.Windows.Input.MouseButtonEventArgs e) {
}
}
}