Skip to content
Simple Recorder based on AudioQueue
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Simple Recorder based on AudioQueue


set AudioSession

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

init & start inputQueue

MCAudioInputQueue *_recorder;
AudioStreamBasicDescription format;
format.mFormatID = kAudioFormatLinearPCM;
format.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
format.mBitsPerChannel = 16;
format.mChannelsPerFrame = 1;
format.mBytesPerPacket = _format.mBytesPerFrame = (_format.mBitsPerChannel / 8) * format.mChannelsPerFrame;
format.mFramesPerPacket = 1;
format.mSampleRate = 8000.0f;

_recorder = [MCAudioInputQueue inputQueueWithFormat:format bufferDuration:0.2 delegate:self];
[_recorder start];

handle data & error

- (void)inputQueue:(MCAudioInputQueue *)inputQueue inputData:(NSData *)data numberOfPackets:(UInt32)numberOfPackets
    //handle data

- (void)inputQueue:(MCAudioInputQueue *)inputQueue errorOccur:(NSError *)error
    //handle error
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.