我不熟悉目标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“的提取似乎不起作用,但我无法为自己找到解决方案。如果有人知道如何解决这个问题,并分享它,我非常感谢。
诚挚的问候。
杜布玉
发布于 2015-03-19 21:00:30
AudioStreamBasicDescription: 0 ch,0 Hz,'lpcm' (0x0000000E) 16-bit signed integer一个问题是您没有指定通道数(请参阅0 ch)。所以你需要指定它。
您应该看到类似于:
AudioStreamBasicDescription: 1 ch, 44100 Hz, 'lpcm' (0x0000000E) 16-bit signed integerhttps://stackoverflow.com/questions/29092279
复制相似问题