KSMidi is a small C++17 helper that reads and writes MIDI through the Windows Kernel Streaming (KS) layer. It avoids WinMM and WinRT so you only deal with the driver.
Maintained by Mohamed Maatallah · 2025.
File | Description |
---|---|
KSMidi.h |
Public header – include and use the API |
KSMidi.cpp |
Implementation – add to one target and link |
main.cpp |
Simple sample: basic lib functionality demo, API benchmark |
test_1.cpp |
MIDI 1.0, and lib functionality tests |
- Create a console project.
- Add the three files above.
- Build and run
main.cpp
.
If you use CMake, just add the two library files to your target.
Classes:
Api
– static helpers to list ports and get detailed info.MidiIn
– read byte streams or UMP packets. Supports polling, threaded callback, or direct callback on the KS I/O thread.MidiOut
– write byte streams or UMP packets.
Other points:
- RAII handles; errors as
KsMidiError
exceptions. - Works with MIDI 1.0 and MIDI 2.0 (UMP helpers included).
- Device info: name, protocol, in‑use flag.
Note: The library sends messages immediately. Incoming data can be timestamped with QPC or the driver’s presentation time.
- Opens pins in shared mode when possible.
- Raises
KsMidiError
if a pin is locked by another app. - WinMM‑only or WinRT‑only virtual ports do not appear.
- Full API guide:
DOCUMENTATION.md
- Planned: vcpkg / Conan package, virtual loopback helper, public latency tests, and MIDI 2.0 tests.
MIT. Bug reports and pull requests are welcome.