EZMicrophone with custom AudioStreamBasicDescription

184 Views Asked by At

I want to record audio from the mic, and I need the audio to be in a specific format. Here's the code I'm trying to run:

AudioStreamBasicDescription asbd;
memset(&asbd, 0, sizeof(asbd));
asbd.mBitsPerChannel   = 16;
asbd.mBytesPerFrame    = 2;
asbd.mBytesPerPacket   = 2;
asbd.mChannelsPerFrame = 1;
asbd.mFormatFlags      = kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
asbd.mFormatID         = kAudioFormatLinearPCM;
asbd.mFramesPerPacket  = 1;
asbd.mSampleRate       = 8000;
self.microphone = [EZMicrophone microphoneWithDelegate:self];
[self.microphone setAudioStreamBasicDescription:asbd];

But the App crash.Here is the screen shot.How to fix it? enter image description here

0

There are 0 best solutions below