From a50a93aff35841e20b61a0d1c2359f257d9881fc Mon Sep 17 00:00:00 2001 From: Simon G Date: Thu, 8 Apr 2021 19:54:38 +0200 Subject: [PATCH] - start implementing midi --- Lib.Audio/Device.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Lib.Audio/Device.cs b/Lib.Audio/Device.cs index bbc5412..bdafa57 100644 --- a/Lib.Audio/Device.cs +++ b/Lib.Audio/Device.cs @@ -5,12 +5,15 @@ using System.Collections.Generic; using Lib.Audio.Factories; using Lib.Audio.Interfaces; +using NAudio.Midi; namespace Lib.Audio { public class Device : IDevice { private readonly IDeviceButtonConfiguration _buttonConfiguration; + private readonly MidiIn _midiIn; + private readonly MidiOut _midiOut; public Device(IChannelFactory channelFactory) { @@ -19,8 +22,26 @@ namespace Lib.Audio Channels = new List(); for (uint i = 0; i < 8; i++) //FixMe: remove hard coded config Channels.Add(channelFactory.Create(i, _buttonConfiguration)); + + var test = MidiIn.NumberOfDevices; + _midiIn = new MidiIn(0); + _midiOut = new MidiOut(0); + + _midiIn.MessageReceived += OnMidiInMessageReceived; + _midiIn.ErrorReceived += OnMidiInErrorReceived; + _midiIn.Start(); } - + public List Channels { get; } + + private void OnMidiInMessageReceived(object? sender, MidiInMessageEventArgs args) + { + int i = 0; + } + + private void OnMidiInErrorReceived(object? sender, MidiInMessageEventArgs args) + { + int i = 0; + } } } \ No newline at end of file