Midi notes can be played using MMSDK very easily, using the MMSDK and any Managed .Net 2.0 Framework supporting language like C#. Its so simple, just adding the Reference to MMSDK.dll to the solution and import the namespace MMSDK.Audio.Midi, and you are done.


The idea behind development of MMSDK is to simplify the task of developing Multimedia enriched applications from .NET platform. It is an Active Project, and in this article, we will be introduced to the CMidi class in detail to play Midi Notes programmatically.


Download the SDK, that is, MMSDK.dll from Sourceforge and just add reference to MMSDK.dll, to the active solution. This is the very first step, and then you are ready to implement the code that will use the API. Now, to use the Software Synthesizer just write the line: using MMSDK.Audio.Midi. Then write the code below and the sound will play.

  1. Initializing the Midi Synthesizer.
                    	CMidi mid = new CMidi();
  2. Select Musical instrument for the channels.
                    	// Select Accordian for Channel 0
                    	mid.Instrument(0, MMSDK.Audio.Midi.InstrumentEnum.Accordian); 
                    	// Select Accordian for Channel 1
                    	mid.Instrument(1, MMSDK.Audio.Midi.InstrumentEnum.AcousticGrandPiano); 
  3. Play a note on Channel 0 for specified time.
                    	// Play Natural C for 2.5 s 
                    	mid.PlaySoundW(0, MMSDK.Audio.Midi.NoteEnum.C, 5, 0xff, 2500);
  4. Turn a note on for Channel 0
                    	// Turn on Natural G <br />
                        mid.NoteOn(0, MMSDK.Audio.Midi.NoteEnum.C, 5, 0xff);
  5. Play the G chord on Channel 1
                    	// Play the Natural G major on Channel 1
                        mid.ChordOn(1, MMSDK.Audio.Midi.ChordEnum.G, 5, MMSDK.Audio.Midi.ChordSideEnum.Right, 0xff);
  6. Sleep and wait for 3 seconds (say).
  7. Turn off the note and the chord
                    	// Turn off Chord <br />
                        mid.ChordOff(1, MMSDK.Audio.Midi.ChordEnum.G, 5, MMSDK.Audio.Midi.ChordSideEnum.Right, 0xff);
                        // Turn off Note<br />
                        mid.NoteOff(0, MMSDK.Audio.Midi.NoteEnum.C, 5, 0xff);                 

This was pretty easy, and hence could be used by anyone, even with minimal programming knowledge. For obtaining the SDK, and more help on the respective classes in it refer to the online documentation link:


The foremost target of the API is to simplify the multimedia programming in managed applications. And this article demostrates the simplified coding to play Midi Notes using the Software Synthesizer. The API is an Active Project, so more classes are being added to achive more out of MMSDK. And I will write more interesting articles about the facilities provided by the SDK. There are more sample applications also hosted alongwith the SDK on sourceforge, you can check them out.

推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架