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

MIDI Instruments

Oct 2, 2011 at 11:59 PM

Hi, I'm pretty new to working with sound in applications, and considering there aren't copious tutorials on NAudio, I'm a little lost. How can I create the sounds of different instruments using NAudio.Midi? Do I have to create some sort of definition for them? Thanks!

Oct 6, 2011 at 4:47 PM

NAudio.MIDI can be used for creating MIDI files as well as send MIDI short messages to MIDI out devices. You will need to understand about MIDI events to be able to do this. For example PatchChangeEvent NoteOnEvent NoteOffEvent etc.

Oct 8, 2011 at 12:48 AM

Here's the code I have currently:

MidiEventCollection collection = new MidiEventCollection(0, 120);
            collection.AddEvent(new NoteEvent(1, 1, MidiCommandCode.NoteOn, 45, 100), 0);
            collection.AddEvent(new NoteEvent(300, 1, MidiCommandCode.NoteOff, 45, 0), 0);
            collection.AddEvent(new NoteEvent(200, 1, MidiCommandCode.NoteOn, 49, 127), 0);
            collection.AddEvent(new NoteEvent(400, 1, MidiCommandCode.NoteOff, 49, 0), 0);

            MidiFile.Export("tempFile.mid", collection); 
I've figured out what pretty much all of this does, and changing the channel has no effect (except when it's changed to 10). Do I need to own a tangible MIDI output device, or can I instruct the program to play a different instrument. (Sorry for being ignorant on the matter, but as I said, there aren't many tutorials on NAudio.)

Oct 17, 2011 at 10:55 AM

Windows has a software synthesizer that will be used to play MIDI files if you play them using Windows media player