开发者

Strange sluggish sound recording from AudioUnit

开发者 https://www.devze.com 2023-01-21 08:34 出处:网络
The following code sounds very sluggish. What\'s wrong? AudioStreamBasicDescription audioFormat; audioFormat.mSampleRate = 22050.0;

The following code sounds very sluggish. What's wrong?

AudioStreamBasicDescription audioFormat;
audioFormat.mSampleRate = 22050.0;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBytesPerFrame = 2;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBitsPerChannel = 16;
audioFormat.mReserved = 0;
audioFormat.mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger |
kL开发者_如何学运维inearPCMFormatFlagIsPacked;

//NSString* recordFilePath=[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.caf"];
NSString* recordFilePath=@"/recordedFile.caf";

NSURL *toURL = [NSURL fileURLWithPath:recordFilePath];





ExtAudioFileCreateWithURL((CFURLRef)toURL, 
                          kAudioFileCAFType, 
                          &audioFormat,
                          NULL, 
                          kAudioFileFlags_EraseFile, 
                          &extAudioFile);

ExtAudioFileSetProperty(extAudioFile,
                      kExtAudioFileProperty_ClientDataFormat, 
                       sizeof(AudioStreamBasicDescription), 
                       &audioUnitOutputFormat);

ExtAudioFileSeek(extAudioFile, 0);

[self EnableAudioInputiPhone];


Is the actual recording sample rate 44100, contrary to your specified file format?

0

精彩评论

暂无评论...
验证码 换一张
取 消