NOW LOADING

App SDK Support for Network MIDI 2.0 Endpoints


Namespace for creating and managing Network MIDI 2.0 (UDP) hosts and clients
Windows.Devices.Midi2.Transports.Network

Types for creating, removing, and monitoring Network MIDI 2.0 hosts and client connections at runtime, and for discovering Network MIDI 2.0 hosts advertised on the local network.

Everything here is reached through the static MidiNetworkTransportManager class.

Definitions

Network MIDI 2.0 uses the terms Host and Client for the two ends of a session. They describe which end accepts and which end initiates, not which end sends MIDI messages — data flows both ways once a session is established.

  • Host: Windows MIDI Services listens on a UDP port and accepts sessions from remote clients. Typically one per PC. Optionally advertised over mDNS.
  • Client: Windows MIDI Services connects out to a remote host, either one discovered over mDNS or one addressed directly by host name / IP address and port.

A single PC can be both at the same time.

Prerequisites

  • The Network MIDI 2.0 transport is installed and enabled in the service
  • midisrv.exe is allowed through Windows Firewall and any other firewall in use
  • For discovery, mDNS is running on the PC and permitted on the network. Windows MIDI Services uses the built-in Windows mDNS support, not Bonjour
  • Direct connections by address and port do not require mDNS and are not limited to the local subnet, provided routing and firewalls allow it

Typical flows

Creating a host so other devices can connect to this PC

  1. Fill in a MidiNetworkHostCreationConfig
  2. await MidiNetworkTransportManager.CreateNetworkHostAsync(config)
  3. Check Success on the returned MidiNetworkHostCreationResponse

CreateNetworkHostAsync does not return until the host is actually running, so a successful result means the host is live and, if requested, advertising.

Connecting to a remote host

  1. Discover hosts with a MidiNetworkAdvertisedHostWatcher, or address one directly
  2. Fill in a MidiNetworkClientConnectConfig with a MidiNetworkClientMatchCriteria
  3. await MidiNetworkTransportManager.ConnectNetworkClientAsync(config)

Approving remote clients

A host configured to require approval answers an unknown remote with “pending” rather than accepting it. Poll GetPendingRemoteClients() and resolve each one with ApproveOrDenyRemoteClientConnectRequestAsync. There is no notification from the service, so polling every few seconds is the expected pattern.

Reconnection behavior

Once a client has been configured, the service manages the connection for you. What it does when a remote host goes away depends on how the client was configured, because the two cases give the service different information to work with.

Situation Discovered (mDNS) client Direct address client
Host not present at startup Connects when the host advertises One attempt, then marked Unavailable
Host goes away and returns Reconnects when it advertises again One further attempt, then Unavailable
Never answered Retried whenever it advertises Marked Unavailable

A direct address is never retried on a timer. Nothing announces that a fixed IP address has come back, so polling it would put invitations on the wire indefinitely for every unreachable address in a user’s configuration. To retry one, call ConnectNetworkClientAsync again with the same ClientId — for an entry which already exists, this acts as an “it is reachable now, try again” signal.

Use MidiNetworkConfiguredClient.EntryState to surface this in a UI. See MidiNetworkClientEntryState.

Persistence

Hosts and clients created through this API are transient and disappear when the service restarts. To persist them, the creating application also writes the equivalent entry to the configuration file. The Windows MIDI Services Settings app does this for you.

The service reads allowedClients and deniedClients lists for each host from the configuration file at startup, so remote client decisions saved by an app are honored on the next run. The service itself never writes to the configuration file.

Current limitations

  • Authentication is not implemented. A host configured to require it is rejected at configuration time rather than silently accepting unauthenticated connections. See issue 733
  • mDNS discovery is limited to the local subnet. Direct connections are not
  • mDNS discovery can be slow to settle. midimdnsinfo.exe in the SDK tools is useful for checking what is visible on the network

Types in this namespace

Click or tap the type name to view more details.

Type Description
MidiNetworkAdvertisedHost A Network MIDI 2.0 host discovered on the network over mDNS
MidiNetworkAdvertisedHostAddedEventArgs Event args for a Network MIDI 2.0 host appearing on the network
MidiNetworkAdvertisedHostRemovedEventArgs Event args for a Network MIDI 2.0 host disappearing from the network
MidiNetworkAdvertisedHostUpdatedEventArgs Event args for a change to an advertised Network MIDI 2.0 host
MidiNetworkAdvertisedHostWatcher Watches the network for Network MIDI 2.0 hosts appearing and disappearing
MidiNetworkAuthenticationType Authentication required by a Network MIDI 2.0 host
MidiNetworkClientConnectConfig Config sent to the service to connect to a remote Network MIDI 2.0 host
MidiNetworkClientConnectErrorCode Error codes returned when connecting to a remote Network MIDI 2.0 host
MidiNetworkClientConnectResponse Result of a request to connect to a remote Network MIDI 2.0 host
MidiNetworkClientDisconnectConfig Config sent to the service to disconnect a Network MIDI 2.0 client
MidiNetworkClientDisconnectErrorCode Error codes returned when disconnecting a Network MIDI 2.0 client
MidiNetworkClientDisconnectResponse Result of a request to disconnect a Network MIDI 2.0 client
MidiNetworkClientEntryState Where a configured Network MIDI 2.0 client entry is in its life
MidiNetworkClientMatchCriteria Describes how to locate the remote host a client should connect to
MidiNetworkConfiguredClient Information about a Network MIDI 2.0 client connection configured in the service
MidiNetworkConfiguredHost Information about a Network MIDI 2.0 host configured in the service
MidiNetworkHostCreationConfig Config sent to the service to create a Network MIDI 2.0 host
MidiNetworkHostCreationErrorCode Error codes returned when creating a Network MIDI 2.0 host
MidiNetworkHostCreationResponse Result of a request to create a Network MIDI 2.0 host
MidiNetworkHostRemovalConfig Config sent to the service to remove a Network MIDI 2.0 host
MidiNetworkHostRemovalErrorCode Error codes returned when removing a Network MIDI 2.0 host
MidiNetworkHostRemovalResponse Result of a request to remove a Network MIDI 2.0 host
MidiNetworkHostUpdateErrorCode Error codes returned when starting or stopping a Network MIDI 2.0 host
MidiNetworkHostUpdateResponse Result of a request to start or stop a Network MIDI 2.0 host
MidiNetworkPendingRemoteClient A remote client waiting for a user decision before it may connect
MidiNetworkRemoteClientApprovalConfig Config sent to the service to approve or deny a waiting remote client
MidiNetworkRemoteClientApprovalErrorCode Error codes returned when approving or denying a remote Network MIDI 2.0 client
MidiNetworkRemoteClientApprovalResponse Result of approving or denying a waiting remote client
MidiNetworkTransportManager The primary class used to create, remove, and monitor Network MIDI 2.0 hosts and client connections

Didn't find what you were looking for?

Windows MIDI Services is an open source project with all source available on GitHub. We have a great community on Discord as well. Between GitHub and Discord, you should find the information you are looking for.