         Int(self.list.pointee.numPackets)
     }
 
-    var remaining: Int {
+    public var remaining: Int {
         byteSize - occupied
     }
 

}

extension MIDIPacketListBuilder: Sequence {
    public typealias Element = UnsafeMutablePointer<MIDIPacket>

    public func makeIterator() -> AnyIterator<Element> {
        self.list.makeIterator()
    }
}

extension UnsafeMutablePointer where Pointee == MIDIPacket {
//    public var startIndex: Int {
//        fatalError()
//    }

        }
    }
}
import AVFoundation

public typealias AUMIDIPacketBlock = (AUEventSampleTime, UInt8, UnsafePointer<MIDIPacket>) -> Void
public typealias AUMIDIPacketListBuilderBlock = (AUEventSampleTime, UInt8, MIDIPacketListBuilder) -> Void

extension AUAudioUnit {
    public var scheduleMIDIPacketBlock: AUMIDIPacketBlock? {
        guard let block = self.scheduleMIDIEventBlock else { return nil }
        return {(ts, channel, ptr) in
            ptr.withUnsafeBytes {
                block(ts, channel, ptr.count, $0)
            }
        }
    }

    public var scheduleMIDIPacketListBuilderBlock: AUMIDIPacketListBuilderBlock? {
        guard let block = self.scheduleMIDIPacketBlock else { return nil }
        return {(ts, channel, list) in
            for e in list {
                block(ts, channel, e)
            }
        }

    }
}
