This project has moved. For the latest updates, please go here.

Playing Midi Files

Jan 29, 2013 at 11:35 AM
Edited Jan 29, 2013 at 11:39 AM

Anyone got example/tips on how to play Midi files using NAudio?

All I have found is sending note signals to midi synthesizer


midiOut.Send(MidiMessage.ChangePatch(47, 0).RawData);


But looping through each note over 10+ tracks is a mess!

Also another question, I have lots of wav files sorted into instruments and notes. How would I use my own wav files to play the midi? or sf2 files? (my own synthesizer?)

Jan 29, 2013 at 1:10 PM

I'm afraid I never got round to implementing MIDI file playback in NAudio. My focus at the time I did MIDI was much more on manipulating MIDI files. I do think that some of the midiStream APIs can do it, but the wrappers for them in NAudio are only partially complete.

If you're making your own synth, then you'd probably be implementing the sequencer yourself anyway as it wouldn't appear to Windows as a MIDI device. The drum machine demo I added to the NAudio WPF Demo project might point you in the right direction for doing this. However, drums are usually "one-shot" whilst other MIDI notes must respond to the note-off message at the right time.

Oct 20, 2014 at 11:54 PM
Any progress on this subject?