<!--
{
  "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:)-35k1c",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioEngine(im)connectMIDI:toNodes:format:eventListProvider:"
  },
  "title" : "connectMIDI(_:to:format:eventListProvider:)"
}
-->

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

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

## Parameters

`sourceNode`

The source node.

`destinationNodes`

An array of AVAudioNodes specifying destination nodes.

`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 a source node and multiple destination nodes.

Use this method to establish a MIDI only connection between a source node and
multiple destination nodes.

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`.

MIDI connections made using this method are either one-to-one (when a single
destination connection is specified) or one-to-many (when multiple connections are
specified), but never many-to-one.

Note that any pre-existing 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)