Powered by Blogger.
Showing posts with label RtMidi. Show all posts
Showing posts with label RtMidi. Show all posts

Use RtMidi in Windows in a Microsoft Visual Studio C++ Project

Sunday, May 12, 2013

Create a "Win32 Console Application" in Visual Studio.


Name it, click OK.


Click next.


Deselect "Precompiled header" and select "Empty project", click Finish.

Add a C++ (.cpp) file, name it and click Add.


Copy the code of "midiout.cpp" from this link to your .cpp file.
Change "SLEEP" in the code to "Sleep". (Since we are using Windows)
Add "#include " at the beginning of the code.
Copy "RtMidi.cpp", "RtMidi.h" and "RtError.h" files to your project folder. You can find these files from here.

Right click on your project in VS -> Add -> Existing item.
Select and add above three files to your project.


Now your project file structure will look like this.


Add "#define __WINDOWS_MM__" line at the beginning of the "RtMidi.h" file.


Right click on your project in VS -> Properties.


Go to Configuration properties -> Linker -> Input. Add "winmm.lib" at the end of "Additional dependencies".


Click Apply and OK.

Go to Visual Studio project. Press "F7". Press "Control key + F5". Then you can see the command prompt and can hear a short beep. If so, your RtMidi now works fine. Good luck!