我有以下代码:
func loadSoundfont(_ pitch : String) {
let path: String = Bundle.main.path(forResource: "\(self.id)/\(pitch)", ofType: "f32")!
let url = URL(fileURLWithPath: path)
do {
let file = try AVAudioFile(forReading: url, commonFormat: AVAudioCommonFormat.pcmFormatFloat32, interleaved: true)
let format = file.processingFormat
let capacity = AVAudioFrameCount(file.length)
self.buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: capacity)
try file.read(into: self.buffer!)
} catch let error as NSError {
print("ERROR HERE", error.localizedDescription)
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:1954115647这是:kAudioFileUnsupportedFileTypeError
我的A4.f32文件包含PCM浮点32。在这里我缺少什么吗?我的文件中没有标题,是否可能导致此问题?