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.
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.
A single PC can be both at the same time.
midisrv.exe is allowed through Windows Firewall and any other firewall in useCreating a host so other devices can connect to this PC
await MidiNetworkTransportManager.CreateNetworkHostAsync(config)Success on the returned MidiNetworkHostCreationResponseCreateNetworkHostAsync 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
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.
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.
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.
midimdnsinfo.exe in the SDK tools is useful for checking what is visible on the networkClick 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 |