I've been messing around with MIDI files in swift. After converting the file to a string with
for byte in readFile {
let hex = String(format: "%02x", UInt(byte))
hexString.append(contentsOf: hex)
}
But now I've made the modifications to the hex string I need to write it back to a new MIDI file with the correct encoding. I'm assuming I need to use something like:
hexString.write(to: opUrl, atomically: false, encoding: String.Encoding.utf8)
But the encoding is obviously wrong. I'm a bit confused in this area so any help would much be much appreciated. Also if anyone can give an idiot proof explanation of the atomically:
option that would be a bonus!