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.
发表评论
upzpjE This is a topic that is close to my heart Best wishes! Where are your contact details though?
J8a7um You made some good points there. I looked on the internet for the subject and found most guys will approve with your website.
7NUyMm Thanks for sharing this first-class post. Very inspiring! (as always, btw)
soh2Tf I'аve read various fantastic stuff here. Undoubtedly worth bookmarking for revisiting. I surprise how a whole lot try you set to generate this form of great informative internet site.
Very nice blog post. I certainly appreciate this site. Thanks!
eJkyIj Way cool! Some very valid points! I appreciate you penning this post and also the rest of the website is extremely good.
I’m relatively sure I will learn many new stuff right here!
Gravity he mr sixteen esteems. Mile home its new means with high told said.
Very good article.Thanks Again. Great.
A round of applause for your post.Much thanks again. Fantastic.
It as exhausting to search out educated people on this matter, but you sound like you know what you are speaking about! Thanks
Im obliged for the article.Really looking forward to read more. Cool.
I?ve learn a few good stuff here. Definitely price bookmarking for revisiting. I surprise how a lot attempt you set to create this type of fantastic informative web site.
You, my friend, ROCK! I found just the information I already searched all over the place and just could not locate it. What a perfect website.
Outstanding post, I conceive people should learn a lot from this site its very user genial. So much superb information on here .
Wow, that as what I was looking for, what a stuff! present here at this website, thanks admin of this site.
Thanks a lot for the blog post.Really thank you! Really Great.
you continue to care for to stay it sensible. I can not wait to read
Pretty! This was an extremely wonderful article. Thanks for providing this information.
serenity malibu I am struggling with this problem, unknowingly i started importing other person blog posts..which i want to disable. Please help me out.
You should really control the remarks on this site
Way cool! Some extremely valid points! I appreciate you penning this post and the rest of the website is extremely good.
Magnificent website. Lots of helpful information here. I'аm sending it to several pals ans also sharing in delicious. And certainly, thank you to your sweat!
There is noticeably a bundle to know about this. I assume you made sure nice points in options also.
Major thankies for the article.Thanks Again. Really Great.
Really appreciate you sharing this article.Thanks Again.
Thank you for your post.Thanks Again. Much obliged.
This is really interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post. Also, I ave shared your website in my social networks!
Very rapidly this website will be famous among all
rates my Website she admits she utilizes a secret weapon to help you shed weight on her walks.
I'аve learn some good stuff here. Definitely worth bookmarking for revisiting. I wonder how so much attempt you place to create this sort of fantastic informative website.
IaаАабТТаЂааАабТТаБТll create a hyperlink towards the internet page about my private weblog.
Pretty! This has been an incredibly wonderful article. Many thanks for supplying this info.
Major thankies for the article.Really thank you! Want more.
your RSS. I don at know why I am unable to subscribe to it. Is there anyone else having similar RSS issues? Anyone that knows the answer can you kindly respond? Thanks!!
Very nice post. I just stumbled upon your blog and wanted to say that I ave really enjoyed browsing your blog posts. After all I all be subscribing to your rss feed and I hope you write again soon!
Its hard to find good help I am forever saying that its difficult to find quality help, but here is
Major thankies for the blog article.Thanks Again. Great.
whoah this blog is wonderful i love reading your articles. Keep up the good work! You know, many people are searching around for this info, you could help them greatly.
This very blog is obviously entertaining as well as amusing. I have picked helluva interesting things out of this blog. I ad love to go back again and again. Thanks a lot!
Thank which you bunch with regard to sharing this kind of with all you genuinely admit a minute ago what you are speaking approximately! Bookmarked. Entertain also obtain guidance from my web page
IE still is the marketplace chief and a huge section of other
This blog is definitely interesting as well as amusing. I have found helluva helpful advices out of this amazing blog. I ad love to go back again soon. Thanks a lot!
Im obliged for the blog post.Much thanks again. Want more.
pretty useful stuff, overall I feel this is really worth a bookmark, thanks
This is my first time go to see at here and i am really pleassant to read all at alone place.
This is a really good tip particularly to those new to the blogosphere. Short but very precise information Many thanks for sharing this one. A must read article!
Thanks again for the blog.Much thanks again.
out the entire thing without having side-effects , folks could take a signal.
or guest authoring on other blogs? I have a blog based upon on the same topics you discuss and would love to have you share some stories/information.