KDMAPI (Keppy's Direct MIDI API) wrapper for Python
kdmapi provides both C bindings for OmniMIDI.dll and a Python-friendly wrapper for them
A Mido backend is also provided, instructions on how to use it are below
Requires Python 3.8 or greater
pip3 install kdmapi
You will also need to have OmniMIDI installed
from kdmapi import KDMAPI
# Initialize the device
KDMAPI.InitializeKDMAPIStream()
# Send a short 32-bit MIDI message data
KDMAPI.SendDirectData(0x0)
# Close the device
KDMAPI.TerminateKDMAPIStream()
You can use KDMAPI as a Mido output backend
import mido
# Set KDMAPI as MIDO backend
mido.set_backend("kdmapi.mido_backend")
# Open MIDI file
midi_file = mido.MidiFile("your_file.mid")
with mido.open_output() as out:
for msg in midi_file.play():
out.send(msg)
#
# Copyright (C) 2022 Sebastiano Barezzi
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#