---
title: "connectMIDI(_:to:format:block:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudioengine/connectmidi(_:to:format:block:)-666bc"
---

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

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

## Declaration

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

## Parameters

- `sourceNode`: The source node.
- `destinationNodes`: An array of doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioNode objects that specify 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 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.

## See Also

### Managing MIDI Nodes

- [connectMIDI(_:to:format:eventListProvider:)](avfaudio/avaudioengine/connectmidi(_:to:format:eventlistprovider:)-8tmk8.md)
- [connectMIDI(_:to:format:eventListProvider:)](avfaudio/avaudioengine/connectmidi(_:to:format:eventlistprovider:)-35k1c.md)
- [connectMIDI(_:to:format:eventListBlock:)](avfaudio/avaudioengine/connectmidi(_:to:format:eventlistblock:)-73cd1.md)
- [connectMIDI(_:to:format:eventListBlock:)](avfaudio/avaudioengine/connectmidi(_:to:format:eventlistblock:)-7qtd5.md)
- [disconnectMIDI(_:from:)](avfaudio/avaudioengine/disconnectmidi(_:from:)-1kssy.md)
- [disconnectMIDI(_:from:)](avfaudio/avaudioengine/disconnectmidi(_:from:)-7oaab.md)
- [disconnectMIDIInput(_:)](avfaudio/avaudioengine/disconnectmidiinput(_:).md)
- [disconnectMIDIOutput(_:)](avfaudio/avaudioengine/disconnectmidioutput(_:).md)
- [connectMIDI(_:to:format:block:)](avfaudio/avaudioengine/connectmidi(_:to:format:block:)-3bc13.md)
