First of all: I really want to save the array as .txt
file. .plist
is out of the question.
The reason: Afterwards I want to save it to a vector using C++. Realizing this with a wrapper already drove me crazy.
Here is my code:
guard let buf = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: AVAudioFrameCount(file.length))
else{ throw NSError()}
try file.read(into: buf)
guard buf.floatChannelData != nil else{print("Channel Buffer konnte nicht erstellt werden")
throw NSError()}
let samples = Array(UnsafeBufferPointer(start:buf.floatChannelData![0],count:Int(buf.frameLength)))
var wData = Data(samples)
try! wData.write(to: outputURL())
But it is not possible to initialize Data with Float values, or is it?
How can I write an Array of float Values into a .txt
file?