Module: MIDICommunicationsWindows

Defined in:
lib/midi-communications-windows.rb,
lib/midi-communications-windows/api.rb,
lib/midi-communications-windows/input.rb,
lib/midi-communications-windows/device.rb,
lib/midi-communications-windows/output.rb,
lib/midi-communications-windows/message.rb,
lib/midi-communications-windows/version.rb,
lib/midi-communications-windows/type_conversion.rb

Overview

Windows-specific MIDI I/O through the Windows Multimedia (WinMM) API.

This library gives low-level access to MIDI ports on Windows by binding winmm.dll with FFI. It is normally used through the higher-level midi-communications gem, which selects it automatically on Windows.

The classes are Input, for receiving, and Output, for sending. Device enumerates both.

Why WinMM, and not one of the newer APIs

Windows has three MIDI APIs a program could use. WinMM is the oldest, and as of February 2026 it is also the most sensible choice for Ruby.

Windows MIDI Services, generally available in Windows 11 since then, replaced the MIDI stack underneath. The existing MIDI 1.0 APIs were reconnected to the new service rather than retired, so a WinMM client reaches what the new stack offers with nothing installed — including the loopback endpoints the system now creates itself, which used to need a third-party driver.

Whether a port can be opened by more than one program at a time follows the endpoint, not the API. Measured: two clients shared a loopback input and both received every message, while a second open of a classic wdmaud device was refused as already in use. On Windows 10 there is no Windows MIDI Services.

The new App SDK offers MIDI 2.0 and UMP, which this library does not need — midi-communications and MusaDSL are MIDI 1.0 throughout — and it is published only as WinRT. Microsoft's own guidance is that other languages need a WinRT projection from their toolchain, and Ruby has none.

Why no compiled artifact

winmm.dll is present on every Windows installation, so this gem binds a library that is already there and ships no binary of its own. The only compiled dependency is ffi itself, which is published for every Windows platform including ARM64. Distributing platform-specific binaries through RubyGems is where installations break; there is nothing here to break.

Examples:

List the output ports

MIDICommunicationsWindows::Output.all.each do |output|
  puts "#{output.id}: #{output.name}"
end

Send a note

output = MIDICommunicationsWindows::Output.first
output.open
output.puts(0x90, 60, 100)

See Also:

Defined Under Namespace

Modules: API, Device, Message, TypeConversion Classes: Error, Input, Output

Constant Summary collapse

VERSION =

Current version of the midi-communications-windows gem.

'1.0.0'.freeze