PortMidi provides bindings for the PortMusic MIDI API.


If you downloaded a prebuilt copy, the library should run on recent Unix- or Windows-based .NET 4.0 environments. It has been developed for and tested on Linux with Mono 4.0.

To build PortMidi from source you will need an F# 3.0 compiler and .NET development environment. The .fsproj and .sln files in the source directory should be understood by command line tools like Microsoft's msbuild or Mono's xbuild as well as IDEs such as MonoDevelop or VisualStudio.


PortMidi provides a few utilities to construct MIDI events and to handle timing. Apart from that it allows you to construct disposable PortMidi.MidiInputStream or PortMidi.MidiOutputStream objects that wrap the native library functionality.

A simple MIDI output example may look like this:

open PortMidi

use out = new MidiOutputStream(MidiOutputStream.DefaultDevice, latency = 10)
out.Write(MidiEvent(ProgramChange, 0uy))
let events = MidiEvent.WithTimebase( 800 [ Note.C 4; Note.E 4; Note.G 4 ])