I am unfamiliar with Objective-C and audioUnit.
I want to make the iOS app which can save the audio signal from the microphone through some audioUnit effects that sound in the device. so now I am trying to study apple's sample code "AVCaptureToAudioUnit"
https://developer.apple.com/library/ios/samplecode/AVCaptureToAudioUnit/Introduction/Intro.html (build with Xcode 6.1 and simulator iphone5.)
but It exposed the error below
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)
these logs written in method of CaptureSessionController.mm below
- (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);
}
}
}
it seems that the extraction of "currentInputASBD" don't work, but I couldn't find the solution for myself. If anyone knows how to fix this issue and share it , I highly appreciate.
best regards.
dubryu
AudioStreamBasicDescription: 0 ch,0 Hz,'lpcm' (0x0000000E) 16-bit signed integer
One problem is that you have not specified the number-of-channels (see 0 ch). So you need to specify it.
You should see something similar to:
AudioStreamBasicDescription: 1 ch, 44100 Hz, 'lpcm' (0x0000000E) 16-bit signed integer
User contributions licensed under CC BY-SA 3.0