我正在使用ExtAudioFileCreateWithURL
并在创建Stereo LPCM Float32 Wave文件时始终遇到运行时kAudioFileUnsupportedDataFormatError
错误。我坚持使用Mono(单通道)文件可以正常工作。任何提示?
以下是代码段:
let audioType: AudioFileTypeID = kAudioFileWAVEType
var recordingFormatStream = CAStreamBasicDescription(sampleRate: sampleRate, numChannels: 2, pcmf: .Float32, isInterleaved: false)!
err = ExtAudioFileCreateWithURL(audioFileRecordingURL,
audioType,
&recordingFormatStream,
nil,
AudioFileFlags.EraseFile.rawValue,
&audioRecordingAudioFile)
注意audioFileRecordingURL
和audioRecordingAudioFile
已正确输入并设置。
对于记录,recordingFormatStream
包含:
mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsFloat | kAudioFormatFlagIsNonInterleaved
mFormatID = kAudioFormatLinearPCM
mSampleRate: 44100.0
mBytesPerPacket: 4, mFramesPerPacket: 1, mBytesPerFrame: 4, mChannelsPerFrame: 2, mBitsPerChannel: 32, mReserved: 0
我坚持认为,如果我将numChannels
更改为1,一切都很好!使用iOS 9.3 SDK。
答案 0 :(得分:0)
经过多次努力:SDK 中的ExtAudioFile
方法不接受非交错音频。我相信这是新的!
感谢此帖:Using ExtAudioFileWriteAsync() in callback function. Can't get to run