title: Recording audio in mp3 format in an iPhone app
body: <p>I am developing an iPhone app which records the audio in .wav format.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc]init];         
  [recordSetting setValue :[NSNumber  numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
  [recordSetting setValue:[NSNumber numberWithFloat:11025.0] forKey:AVSampleRateKey];         
  [recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
  [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
  
  
  
  
  NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
   NSUserDomainMask, YES);
  
    NSString *documentsDirectory = [path objectAtIndex:0]; 
  
    NSString *myDBnew = [documentsDirectory stringByAppendingPathComponent:@"test.wav"];
  
   recordedTmpFile = [NSURL fileURLWithPath:myDBnew];
  
  NSLog(@"Using File called: %@",recordedTmpFile);
  
          recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&amp;error];
          [recorder setDelegate:self];
          [recorder prepareToRecord];
          [recorder record];
  </code></pre>
  
  <p>Above code is recording audio in .wav format. If I want to record audio in MP3 using key <code>kAudioFormatMPEGLayer3(mp3)</code> instead of <code>kAudioFormatLinearPCM(.wav)</code>, what other changes do I need to make? Changes in recordSetting dictionary like sample rate, channel and all.</p>
  
  <p>Or suggest any audio format which is compatible with both iPhone and Android, smaller in size and can be recorded directly from iPhone app.</p>