This project has moved and is read-only. For the latest updates, please go here.

Playing Midi Files

Jan 29, 2013 at 12:35 PM
Edited Jan 29, 2013 at 12:39 PM


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 2: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 21, 2014 at 12:54 AM
Any progress on this subject?