---
title: "connectMIDI(_:to:format:eventListProvider:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudioengine/connectmidi(_:to:format:eventlistprovider:)-8tmk8"
---

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

## Declaration

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

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

## See Also

### Managing MIDI Nodes

- [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)
- [connectMIDI(_:to:format:block:)](avfaudio/avaudioengine/connectmidi(_:to:format:block:)-666bc.md)
