You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
// Author: Gockner, Simon
|
|
// Created: 2021-04-09
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved.
|
|
|
|
using System;
|
|
using Lib.Midi.Interfaces;
|
|
using NAudio.Midi;
|
|
|
|
namespace Lib.Midi
|
|
{
|
|
public class MidiCommunication : IMidiCommunication
|
|
{
|
|
private readonly MidiIn _midiIn;
|
|
private readonly MidiOut _midiOut;
|
|
|
|
public MidiCommunication()
|
|
{
|
|
_midiIn = new MidiIn(0); //TODO: don't always use device 0?
|
|
_midiOut = new MidiOut(0);
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
_midiIn.MessageReceived += OnMidiInMessageReceived;
|
|
_midiIn.ErrorReceived += OnMidiInErrorReceived;
|
|
_midiIn.Start();
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
_midiIn.Stop();
|
|
_midiIn.MessageReceived -= OnMidiInMessageReceived;
|
|
_midiIn.ErrorReceived -= OnMidiInErrorReceived;
|
|
|
|
_midiIn.Close();
|
|
_midiOut.Close();
|
|
}
|
|
|
|
public void Send(IMidiMessage message)
|
|
{
|
|
|
|
}
|
|
|
|
private void OnMidiInMessageReceived(object? sender, MidiInMessageEventArgs args)
|
|
{
|
|
int i = 0;
|
|
}
|
|
|
|
private void OnMidiInErrorReceived(object? sender, MidiInMessageEventArgs args)
|
|
{
|
|
int i = 0;
|
|
}
|
|
|
|
public event EventHandler<IMidiMessage>? MessageReceived;
|
|
}
|
|
} |