Play Midi Notes using MMSDK and C# (Managed Platform)
Introduction
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.
Background
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.
Using MMSDK
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.
- Initializing the Midi Synthesizer.
CMidi mid = new CMidi();
- 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);
- 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);
- Turn a note on for Channel 0
// Turn on Natural G <br /> mid.NoteOn(0, MMSDK.Audio.Midi.NoteEnum.C, 5, 0xff);
- 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);
- Sleep and wait for 3 seconds (say).
System.Threading.Thread.Sleep(3000);
- 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: http://arnavguddu.6te.net/mmsdk
Conclusion
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.
发表评论
Thankyou for all your efforts that you have put in this. very interesting information.
Psoriasis light Treatment How can I obtain a Philippine copyright for my literary articles and/or books?
Thanks again for the blog post.Much thanks again. Keep writing.
If some one needs expert view on the topic of blogging
Wow! Thank you! I permanently needed to write on my blog something like that. Can I take a portion of your post to my blog?
I was able to find good information from your content.
Well I really enjoyed reading it. This post procured by you is very constructive for correct planning.
wow, awesome blog article.Really looking forward to read more. Fantastic.
Very good post. I am going through many of these issues as well..
There as definately a great deal to learn about this subject. I really like all of the points you made.
Very nice article and straight to the point. I am not sure if this is truly the best place to ask but do you folks have any ideea where to employ some professional writers? Thank you
very good publish, i actually love this web site, carry on it
Wow! Thank you! I permanently needed to write on my blog something like that. Can I take a fragment of your post to my blog?
Some genuinely choice blog posts on this website , bookmarked.
Major thanks for the blog article.Thanks Again. Want more. this link
Ridiculous quest there. What occurred after? Thanks!
I'аve read a few excellent stuff here. Definitely price bookmarking for revisiting. I surprise how so much effort you place to make this kind of magnificent informative web site.
I required to thank you for this interesting We definitely loved each tiny tad of it. I have you bookmarked your identifiable web place to ensure outdated the newest things a person publish.
Thank you ever so for you blog post.Really looking forward to read more. Really Great.
Regards for this wondrous post, I am glad I detected this web site on yahoo.
Major thanks for the blog article. Fantastic.
Wow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is great, as well as the content!
It kind of feels that you are doing any distinctive trick.
It is in reality a nice and useful piece of information. I am happy that you shared this helpful information with us. Please keep us informed like this. Thank you for sharing.
You could definitely see your skills within the work you write. The world hopes for even more passionate writers such as you who aren at afraid to say how they believe. All the time follow your heart.
This website was how do I say it? Relevant!! Finally I ave found something which helped me. Thanks!
This very blog is really awesome and also amusing. I have chosen a lot of handy things out of this source. I ad love to come back again soon. Thanks!
Im grateful for the blog post. Fantastic.
Wow, superb blog layout! How long have you ever been blogging for? you make running a blog glance easy. The whole glance of your website is magnificent, let alone the content material!
You can definitely see your expertise within the work you write.
Very good blog article.Really looking forward to read more. Awesome.
Very interesting information!Perfect just what I was looking for! аЂааЂ Washington is the only place where sound travels faster than light.аЂ аЂа by C. V. R. Thompson.
Thanks for sharing, this is a fantastic blog post.Really thank you! Great.
Say, you got a nice post.Really thank you! Cool.
Well I really enjoyed reading it. This information offered by you is very practical for proper planning.
Really informative post.Much thanks again. Awesome.
Really appreciate you sharing this blog post.Really thank you!
redirected here Where can I find the best online creative writing courses? I live in NYC so which colleges offer the best online creative writing course? If not in a college than where else?.
You made some clear points there. I did a search on the subject matter and found most individuals will approve with your blog.
This is a great tip particularly to those new to the blogosphere. Simple but very precise info Many thanks for sharing this one. A must read post!
You are my intake , I possess few blogs and very sporadically run out from to brand.
Only a few blogger would discuss this topic the way you do.,:
Thorn of Girl Excellent information and facts could be identified on this web blog.
There as noticeably a bundle to know about this. I assume you made sure nice factors in features also.
It as not that I want to duplicate your internet internet site, but I really like the style. Could you tell me which style are you using? Or was it custom made?
My brother suggested I might like this web site. He was entirely right. This post actually made my day. You can not imagine just how much time I had spent for this info! Thanks!
Thanks for sharing, this is a fantastic blog.Much thanks again. Want more.
Thanks so much for the article.Really thank you! Cool.
This is a great article in many ways. I can at express how impressed I am with your content. I appreciate your viewpoints and how you make it all so interesting.
Outstanding post, I believe people should larn a lot from this weblog its very user friendly.