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

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

Establishes a MIDI-only connection between two nodes.

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

## Parameters

`sourceNode`

The source node.

`destinationNode`

The destination node.

`format`

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

`tapBlock`

If not `NULL`, the source node’s <doc://com.apple.documentation/documentation/AudioToolbox/AUMIDIOutputEventBlock> calls this block on the real-time thread. The host can tap the MIDI data of the source node through this block.

---

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)