【发布时间】:2015-05-19 11:30:31
【问题描述】:
我不熟悉 Objective-C 和 audioUnit。
我想制作一个 iOS 应用程序,它可以通过一些在设备中发出的 audioUnit 效果来保存来自麦克风的音频信号。 所以现在我正在尝试研究苹果的示例代码“AVCaptureToAudioUnit”
https://developer.apple.com/library/ios/samplecode/AVCaptureToAudioUnit/Introduction/Intro.html (使用 Xcode 6.1 和模拟器 iphone5 构建。)
但它暴露了下面的错误
AudioStreamBasicDescription: 0 ch,0 Hz,'lpcm' (0x0000000E) 16-bit signed integer
2015-03-17 13:44:56.589 AVCaptureToAudioUnit[1462:151210] Failed to setup audio file! (29759)
这些日志写在下面的 CaptureSessionController.mm 方法中
- (void)startRecording
{
if (!self.isRecording) {
OSErr err = kAudioFileUnspecifiedError;
@synchronized(self) {
if (!extAudioFile) {
/*
Start recording by creating an ExtAudioFile and configuring it with the same sample rate and
channel layout as those of the current sample buffer.
*/
// recording format is the format of the audio file itself
CAStreamBasicDescription recordingFormat(currentInputASBD.mSampleRate,
currentInputASBD.mChannelsPerFrame,
CAStreamBasicDescription::kPCMFormatInt16,
true);
recordingFormat.mFormatFlags |= kAudioFormatFlagIsBigEndian;
NSLog(@"Recording Audio Format:");
recordingFormat.Print();
err = ExtAudioFileCreateWithURL(_outputFile,
kAudioFileAIFFType,
&recordingFormat,
currentRecordingChannelLayout,
kAudioFileFlags_EraseFile,
&extAudioFile);
if (noErr == err)
// client format is the output format from the delay unit
err = ExtAudioFileSetProperty(extAudioFile,
kExtAudioFileProperty_ClientDataFormat,
sizeof(graphOutputASBD),
&graphOutputASBD);
if (noErr != err) {
if (extAudioFile) ExtAudioFileDispose(extAudioFile);
extAudioFile = NULL;
}
}
} // @synchronized
if (noErr == err) {
self.recording = YES;
NSLog(@"Recording Started");
} else {
NSLog(@"Failed to setup audio file! (%ld)", (long)err);
}
}
}
似乎“currentInputASBD”的提取不起作用,但我找不到自己的解决方案。 如果有人知道如何解决这个问题并分享它,我非常感谢。
最好的问候。
杜布里
【问题讨论】:
标签: ios objective-c xcode core-audio audio-recording