title: How do you record a PCM audio file on iOS?
body: <p>Is it possible to record a PCM audio file through the microphone? I am trying to record a very short PCM audio file but have struggled so far.</p>
  
  <p>I have tried using an AVAudioRecorder but this doesn't work:</p>
  
  <pre><code>AVAudioSession *session = [AVAudioSession sharedInstance];
  [session setCategory:AVAudioSessionCategoryRecord error:nil];
  NSDictionary* recorderSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
                                    [NSNumber numberWithInt:44100],AVSampleRateKey,
                                    [NSNumber numberWithInt:1],AVNumberOfChannelsKey,
                                    [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
                                    [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
                                    [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
                                    nil];
  NSError* error = nil;
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSURL* outURL = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:@"output.pcm"]];
  recorder = [[AVAudioRecorder alloc] initWithURL:outURL settings:recorderSettings error:&amp;error];
  [recorder prepareToRecord];
  recorder.meteringEnabled = YES;
  [recorder record];
  </code></pre>
  
  <p>It would be much appreciated if someone could point me in the right direction, thank you.</p>