There is a tuple of UInt8's in a struct MIDIPacket. Normal assignment is like this:
import CoreMIDI
let packet = MIDIPacket()
packet.data.0 = 0x02
packet.data.1 = 0x5f
and so on.
This tuple has length of ~128+. There is an array of values, converted, which I would like to assign to the packet beginning at a certain index.
let converted = [0x01, 0x02, 0x5e,...]
var k = packet starting index of assignment
for i in 0..<converted.count {
packet.data(k) = converted[i]
k += 1
}
How do I do this?
subscripting doesn't work: e.g. packet.data[i], while I believe Mirror simply creates a copy of the packet, so assigning to it would not work..
let bytes = Mirror(reflecting: packet.data).children;
for (_, b) in bytes.enumerated() {
}