MIDI support on both Windows (64-bit or 32-bit) and Mac OS X (64-bit) for .Net Standard 2.0 with support for both input and output midi devices, and support the following midi messages:
- Channel Pressure
- Control Change
- Note On / Off
- Pitch Bend
- Polyphonic Key Pressure
- Program Change
- Non-Registered Parameter Number (NRPN) (used to send/receive 14-bit parameter and value)
- System Exclusive (SysEx)
See changelog for version history.
// 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<IMidiInputDevice>();
try
{
foreach (var inputDeviceInfo in MidiDeviceManager.Default.InputDevices)
{
Console.WriteLine($"Opening {inputDeviceInfo.Name}");
var inputDevice = inputDeviceInfo.CreateDevice();
devices.Add(inputDevice);
inputDevice.ControlChange += ControlChangeHandler;
inputDevice.Open();
}
Console.WriteLine("Press any key to stop...");
Console.ReadKey();
}
finally
{
foreach (var device in devices)
{
device.ControlChange -= ControlChangeHandler;
device.Dispose();
}
}
We are using a fork off rtmidi master
branch with a few changes (you can see a diff here between our fork and official repository) to make it possible to build on the platforms we are interested in and with changes to better support .Net P/Invoke.
You can find our fork at micdah/rtmidi.
Special thanks to the contributors (in alphabetical order):