Important alert: (current site time 10/25/2014 12:24:16 PM EDT)
 

winzip icon

Easy MIDI Notes - VB.Net

Email
Submitted on: 1/26/2013 6:32:34 PM
By: Todd S. Spangler 
Level: Beginner
User Rating: By 3 Users
Compatibility: VB.NET
Views: 9586
author picture
 
     UPDATED 01/22/2013 <> Easy MIDI Notes is based off of another developer's hard work (Abadani, I believe) and some streamlining of code which I added for simplification and ease of use. Example app is designed for those who just want to make use of MIDI without having to spend 90% of the time trying to get a darn note to play. The functionality of this code is similar to Matthew Stride's "Midi Note Generator", but this one is for VB.Net 2008, not C++.Net. Feel free to leave comments or questions though. Featues include (features I added): - 1 file for easy code reuse (simply drop the class in your project and your ready to go) - Simple functions to Stop and Play notes - XML Documentation for ease of code use - Easy Instrument Selection - Easy to follow example program which demonstrates Instrument selection, Volume, Pan, and ModWheel control. This app is aimed at those who love music and want to get started creating MIDI apps, but may not be as skilled at developing (but want to learn).

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 9 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

11/9/2011 4:31:29 PM

Help, I would like to learn more about it.
(If this comment was disrespectful, please report it.)

 
11/10/2011 8:44:27 PMTodd S. Spangler

I'll give you an email.
(If this comment was disrespectful, please report it.)

 
1/22/2012 6:21:27 AMDestrii

This code is AMAZING, I cannot thank you enough! Just spend 1 hour hiking through forums looking for a simple MIDI player for VB.net (I'm making a piano simulator) and this has actually saved my life. Easy to use and simple to integrate into an existing project. Thank you!
(If this comment was disrespectful, please report it.)

 
4/6/2012 2:08:06 PMJonathan

Great code - is there a way of recovering from a 'hang' during a PlayMidiNote? Occasionally my computer hangs in mid-note then crashes and re-boots. Thank you.
(If this comment was disrespectful, please report it.)

 
4/9/2012 6:46:21 PMTodd S. Spangler

Hey Jonathan - In the PlayMIDINote function, in the following area:
Catch ex As Exception
put a breakpoint on that line and run it in Debug mode. See if it can tell you what the exception is and try to see if you can handle it. Let me know what the error is. Right now it is just skipping the error basically.
(If this comment was disrespectful, please report it.)

 
4/20/2012 3:57:22 PMTodd S. Spangler

I have a WPF version as well. If anyone wants it, just email me.
(If this comment was disrespectful, please report it.)

 
12/15/2012 12:33:49 PMBryan Dempsey

This code is just what I need for 3D Rhythm Guitar Simulator project I'm working on! Is it fairly straight forward to change the Chorus and Reverb settings? And is there a single note OFF command?
(If this comment was disrespectful, please report it.)

 
1/2/2013 6:49:21 PMTodd S. Spangler

Please see above, I forgot to expose the Note Off command for a single note.
(If this comment was disrespectful, please report it.)

 
1/2/2013 6:55:35 PMTodd S. Spangler

== Go to clsMIDI - LINE 110 after "Sub STOPALLMIDINotes()"
== Add the following code

Sub STOPMIDINote(ByVal Note As Integer)
Inst.StopNote(Note)
End Sub

== Add this to Form1 ==

'Click on the Form (not on a label)
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
m.PlayMIDINote(70, 127) 'Play Note 70
Else
m.STOPMIDINote(70) 'Stop Note 70
End If
End Sub
(If this comment was disrespectful, please report it.)

 
1/19/2013 6:32:46 AMRobin Dove

Thank you for making this excellent code available. Question: Is it possible to define the duration of a note before it begins? I have tried altering m.duration and inst.duration but nothing seems to change.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.