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

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

Establishes a MIDI connection between a source node and multiple destination nodes.

```
func connectMIDI(_ sourceNode: AVAudioNode, to destinationNodes: [AVAudioNode], format: AVAudioFormat?, eventListBlock tapBlock: AUMIDIEventListBlock? = nil)
```

## Parameters

`sourceNode`

The source node.

`destinationNodes`

An array of objects that specify the destination nodes.

`format`

If not `NULL`, the engine uses this value for the format of the source audio node’s output bus. In all cases, the format of the source node’s output bus has to match with the destination node’s output bus format.

`tapBlock`

If not `NULL`, the source node’s event list block calls this on the real-time thread. The host can tap the MIDI data of the source node through this block.

## Discussion

Use this to establish a MIDI connection between a source node and multiple destination nodes that have MIDI input capability. This method disconnects any existing MIDI connection that involves the destination node. When making the MIDI connection, this method overwrites the source node’s event list block.

The source node can only be an [`AVAudioUnit`](/documentation/AVFAudio/AVAudioUnit) node with the type <doc://com.apple.documentation/documentation/AudioToolbox/kAudioUnitType_MIDIProcessor>. The destination node types can be <doc://com.apple.documentation/documentation/AudioToolbox/kAudioUnitType_MusicDevice>, <doc://com.apple.documentation/documentation/AudioToolbox/kAudioUnitType_MusicEffect>, or <doc://com.apple.documentation/documentation/AudioToolbox/kAudioUnitType_MIDIProcessor>.

MIDI connections made with this method specify a single destination connection (one-to-one) or  multiple connections (one-to-many), but never many-to-one.

---

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)