RTP-MIDI
The RTP-MIDI protocol lets device exchange MIDI data over the network, such as Wi-Fi or LAN.
To minimize the latency, I recommend connecting devices using a LAN cable if possible. Using an ad-hoc Wi-Fi network can also give lower latency than having 2 devices communicate via a Wi-Fi router.
macOS
See “Share MIDI information over a network in Audio MIDI Setup on Mac” on Apple Support for more information.
Figure 1. The MIDI Network Setup window in the Audio MIDI Setup app
Windows
Windows users can use the rtpMIDI driver. It is free for private, non-commercial use.
iOS
Use the MIDI Network app to connect your iOS device to other RTP-MIDI capable devices.
Figure 2. The MIDI network app