untroublesome midi

What is this?

This is a class library for manipulating MIDI files. I wrote it because I couldn't find a good .NET class library for manipulating MIDI files.

Details

The library extracts away a lot of the gritty internals of a MIDI file, but it still requires you to understand a few of the basic concepts of a MIDI file: chunks, tracks, and events. Here is some sample code you might write to produce a rather unremarkable MIDI file:

Dim mf As New MIDIFile
Dim t As New Track

mf.Chunks.Add(t)
t.Events.Add(New TimeSignature(0, 4, 4, 24, 8))
t.Events.Add(New ProgramChange(0, 1, 12))
t.Events.Add(New NoteOn(100, 1, 50, 127))
t.Events.Add(New NoteOff(100, 1, 50, 127))
t.Events.Add(New NoteOn(100, 1, 40, 127))
t.Events.Add(New NoteOff(100, 1, 40, 127))
t.Events.Add(New NoteOn(100, 1, 60, 127))
t.Events.Add(New NoteOff(100, 1, 60, 127))
t.Events.Add(New EndofTrack(100))
mf.WriteMIDI("test.mid")

I wrote this library by following some well-written outlines of the MIDI specification and the MIDI file format.

One day, I might extend this library with a few more classes that abstract away some of the obscure knowledge required to construct a MIDI file. I can envision a MIDISong class that uses traditional music notation, time signatures, and instrument listings.

Download

Download a zip file containing the source.

I've also made the documentation available, although you can build it yourself using the NDoc file I've included with the source.