     static let sysExSendRequestFinished = Notification.Name.sysExSendRequestFinished
 
 }
+
+private func customMIDISendSysex(_ request: UnsafeMutablePointer<MIDISysexSendRequest>, _ bufferSize: Int, _ perBufferDelay: Double) -> OSStatus {
+    guard let client = SMClient.sharedClient,
+          bufferSize >= 3 && bufferSize <= 32767 else { return OSStatus(paramErr) }
+
+    if request.pointee.bytesToSend == 0 {
+        request.pointee.complete = true
+    }
+
+    if request.pointee.complete.boolValue {
+        request.pointee.completionProc(request)
+        return OSStatus(noErr)
+    }
+
+    var port = MIDIPortRef()
+    let status = MIDIOutputPortCreate(client.midiClient, "CustomMIDISendSysex" as CFString, &port)
+    if status != noErr {
+        return status
+    }
+
+    let packetListSize = MemoryLayout.offset(of: \MIDIPacketList.packet.data)! + bufferSize
+    let rawPacketListPtr = UnsafeMutableRawPointer.allocate(byteCount: packetListSize, alignment: MemoryLayout<MIDIPacketList>.alignment)
+    let packetListPtr = rawPacketListPtr.initializeMemory(as: MIDIPacketList.self, repeating: MIDIPacketList(), count: 1)
+
+    let queue = DispatchQueue(label: "com.snoize.SnoizeMIDI.CustomMIDISendSysex")
+    queue.setTarget(queue: DispatchQueue.global(priority: .high))
+
+    func sendNextBuffer() {
+        let packetBytes = min(Int(request.pointee.bytesToSend), bufferSize)
+
+        let curPacket = MIDIPacketListInit(packetListPtr)
+        _ = MIDIPacketListAdd(packetListPtr, packetListSize, curPacket, 0, packetBytes, request.pointee.data)
+
+        MIDISend(port, request.pointee.destination, packetListPtr)
+
+        request.pointee.data += packetBytes
+        request.pointee.bytesToSend -= UInt32(packetBytes)
+        if request.pointee.bytesToSend == 0 {
+            request.pointee.complete = true
+        }
+
+        if !request.pointee.complete.boolValue {
+            queue.asyncAfter(deadline: DispatchTime.now() + perBufferDelay) {
+                sendNextBuffer()
+            }
+        }
+        else {
+            request.pointee.completionProc(request)
+
+            MIDIPortDispose(port)
+            rawPacketListPtr.deallocate()
+        }
+    }
+
+    queue.async {
+        sendNextBuffer()
+    }
+
+    return OSStatus(noErr)
+}


        let status: OSStatus
        if customSysExBufferSize >= 4 {
            // TODO
            status = -50
        }
        else {
            // Use CoreMIDI's sender

}

// TODO This notification should maybe just be a delegate method.
public extension Notification.Name {

    static let sysExSendRequestFinished = Notification.Name("SMSysExSendRequestFinishedNotification")
