问题描述
我刚开始使用CoreAudio。只是尝试创建一个音频文件,但是出现了以下的kAudioFileUnsupportedDataFormatError。
I'm just getting started with CoreAudio. Just trying to create an audio file, but getting a kAudioFileUnsupportedDataFormatError with the following.
有人能告诉我为什么吗?在我看来一切都很好,但是我必须做错了。
Can any give me an idea why? It all looks okay to me, but I must be doing something wrong.
// Prepare the format
AudioStreamBasicDescription asbd;
memset(&asbd, 0, sizeof(asbd));
asbd.mSampleRate = SAMPLE_RATE; // 44100
asbd.mFormatID = kAudioFormatLinearPCM;
asbd.mFormatFlags = kAudioFormatFlagIsBigEndian;
asbd.mBitsPerChannel = 16;
asbd.mChannelsPerFrame = 1;
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 2;
asbd.mBytesPerPacket = 2;
// Set up the file
AudioFileID audioFile;
OSStatus audioErr = noErr;
audioErr = AudioFileCreateWithURL((CFURLRef)fileURL,
kAudioFileAIFFType,
&asbd,
kAudioFileFlags_EraseFile,
&audioFile);
推荐答案
核心音频数据类型参考包含参考AudioStreamBasicDescription的材料。但是它非常密集且难以理解。
The "Core Audio Data Types Reference" contains the reference material for AudioStreamBasicDescription. But it's pretty dense and difficult to understand.
iOS的音频单元托管指南中有一个名为使用AudioStreamBasicDescription结构的部分,它会有所帮助。
"Audio Unit Hosting Guide for iOS" has a section called "Working with the AudioStreamBasicDescription structure" that's a bit more helpful.
d。
这篇关于CoreAudio-kAudioFileUnsupportedDataFormatError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!