<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioEngine/connectMIDI(_:to:format:eventListProvider:)-8tmk8",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioEngine(im)connectMIDI:to:format:eventListProvider:"
  },
  "title" : "connectMIDI(_:to:format:eventListProvider:)"
}
-->

# connectMIDI(_:to:format:eventListProvider:)

```
func connectMIDI(_ sourceNode: AVAudioNode, to destinationNode: AVAudioNode, format: AVAudioFormat?, eventListProvider tapBlock: AVMIDIEventListBlock? = nil)
```

## Parameters

`sourceNode`

The source node.

`destinationNode`

The destination node.

`format`

If non-nil, the format of the source node’s output bus is set to this format.
In all cases, the format of the source nodes’ output bus has to match with the
destination nodes’ output bus format.
Although the output bus of the source is not in use, the format needs to be set
in order to be able to use the sample rate for MIDI event timing calculations.

`tapBlock`

This block is called from the source node’s `AUMIDIOutputEventListBlock`
on the realtime thread. The host can tap the MIDI data of the source node through
this block.

## Discussion

\abstract Establish a MIDI only connection between two nodes.

Use this method to establish a MIDI only connection between a source node and a
destination node that has MIDI input capability.

The source node can only be a AVAudioUnit node of type `kAudioUnitType_MIDIProcessor`.
The destination node types can be `kAudioUnitType_MusicDevice`,
`kAudioUnitType_MusicEffect` or `kAudioUnitType_MIDIProcessor`.

Note that any pre-existing MIDI connection involving the destination will be broken.

Any client installed block on the source node’s audio unit `AUMIDIOutputEventListBlock`
will be overwritten when making the MIDI connection.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)