SharpMIDI is an easy to use library for .NET 3.5, written in C# and C++, which allows to use MIDI playback and device query functions on 32 and 64 bit (AMD64) Windows systems.
Developers often encounter problems while implementing MIDI functionality on .NET (e.g. C#). To access MIDI devices one should create a native library -which uses Windows API- and use this library from a .NET application. The main problem is that the resulting .NET assembly is compiled at run-time to native code (32 or 64 bit), but the native libraries have a fixed bitness.
SharpMIDI avoids this problem by containing two native libraries: a 32 and a 64 bit library, written in C++. The .NET dll assembly will choose the proper one depending on the bitness of the operating system.
|SharpMidi.dll||flexible (32/64)||C#||You use only this assembly directly. (.NET 3.5)|
|SharpMidiCPP32.dll||32 bit||C++||32 bit native dll to access Windows API, used by SharpMidi.dll|
|SharpMidiCPP64.dll||64 bit (x64, AMD64)||C++||64 bit native dll to access Windows API, used by SharpMidi.dll|
It’s five functions
SharpMIDI’s aim is to bring these five Windows API functions under the control of the .NET developer.
- midiOutGetNumDevs: gets the number of MIDI devices
- midiOutGetDevCaps: queries information on the given MIDI device
- midiOutOpen: opens MIDI device
- midiOutShortMsg: sends a short MIDI message to the device
- midiOutClose: closes MIDI device
- Flexible: SharpMIDI can be used in any kind of .NET projects (C#, Visual Basic, J#), and on a large scale of Windows systems (32/64 bit variants of XP, Vista, Windows 7, Windows Server 2003 and over) with .NET 3.5 framework installed.
- Object oriented: It’s functionality can be accessed via instantiating proxy objects. Use one Proxy object for one MIDI device.
- Robust exception handling: Contains unique exceptions to represent any error that can appeare on Windows API level. These exceptions are organized hierarchically (by inheritance) to make their handling more flexible.
- Thread safe: Any number of threads can operate on a single proxy object at the same time.
- Easy usage: You can make your MIDI device sound in a couple of source lines. If you have used WIN32 API on MIDI playback before, you can benefit from the acquired knowledge using SharpMIDI. With it you can query the capabilities of a device in a strongly-typed manner.
Contains only binaries, no source code is published.
- SharpMIDI_1_0.zip (19 KByte)
Tutorial and function reference.
- SharpMIDI_MANUAL.pdf (80.4 KByte)
With source code, project files and binaries.
- Example 1 (57 KByte): Play a sound when pushing a button. (Screenshot)
- Example 2 (64 KByte): List devices and query their capabilities. (Screenshot)
SharpMIDI © Tamas Bolner, 2009. All rights reserved.
SharpMIDI can be used freely in any non-commercial software with the proper indication of the author and this web page.