title: Convert audio Linear pcm to mp3 ( using LAME ) Low ,Medium,High audio Quality setting
body: <p>I am encoding a LinearPCM to MP3 in iOS.I'm trying to encode the raw PCM data from microphone to MP3 using AudioToolbox framework and Lame.And although everything seems to run fine if i record an audio it is converted to mp3 with the help of lame encoding concept while play the recorded mp3 audio file working fine.now i want to convert audio(using lame) like low,medium,high quality mp3 file. i don't know exact setting(sample rate,bit depth,bit rate, chennal,quality) while lame conversion process</p>
  
  <pre><code>void AQRecorder::MyInputBufferHandler(  void *                              inUserData,
                                  AudioQueueRef                       inAQ,
                                  AudioQueueBufferRef                 inBuffer,
                                  const AudioTimeStamp *              inStartTime,
                                  UInt32                              inNumPackets,
                                  const AudioStreamPacketDescription* inPacketDesc)
    {
    AQRecorder *aqr = (AQRecorder *)inUserData;
    //    NSLog(@"%f",inStartTime-&gt;mSampleTime);
    try
    {
      if (inNumPackets &gt; 0)
      {
          AudioFileWritePackets(aqr-&gt;mRecordFile, FALSE, inBuffer-&gt;mAudioDataByteSize, inPacketDesc, aqr-&gt;mRecordPacket, &amp;inNumPackets, inBuffer-&gt;mAudioData);
  
          aqr-&gt;mRecordPacket += inNumPackets;
  
          int MP3_SIZE =inBuffer-&gt;mAudioDataByteSize * 4;
          unsigned char mp3_buffer[MP3_SIZE];
          lame_t lame = lame_init();
          lame_set_in_samplerate(lame, 44100);
          lame_set_VBR(lame, vbr_default);
          lame_init_params(lame);
  
    //                int encodedBytes=lame_encode_buffer_interleaved(lame, (short int *)inBuffer-&gt;mAudioData , inNumPackets, mp3_buffer, MP3_SIZE);
  
  
          int encodedBytes = lame_encode_buffer(lame, (short*)inBuffer-&gt;mAudioData,  (short*)inBuffer-&gt;mAudioData, inNumPackets, mp3_buffer, MP3_SIZE);
  
          [delegate.mp3AudioData appendBytes:mp3_buffer length:encodedBytes];
  
          if (inBuffer-&gt;mAudioDataByteSize != 0) {
          }
          else
          {
              int encode=lame_encode_flush(lame, mp3_buffer, MP3_SIZE);
              [delegate.mp3AudioData appendBytes:mp3_buffer length:encode];
          }
          lame_close(lame);
      }
  
      if (aqr-&gt;IsRunning())
      {
          AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL);
      }
    } catch (CAXException e)
   {
   char buf[256];
   fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf));
  }
  }
  </code></pre>