title: AudioRecord and AudioTrack latency
body: <p>I'm trying to develop an aplication like iRig for android, so the first step is to capture the mic input and play it at the same time.</p>
  
  <p>I have it, but the problem is that i get some latency that makes this unusable, and if I start processing the buffer i'm afraid it will get totally unusable.</p>
  
  <p>I use audiorecord and audiotrack like this:</p>
  
  <pre><code>    new Thread(new Runnable() {
          public void run() {
              while(mRunning){
                  mRecorder.read(mBuffer, 0, mBufferSize);
                  //Todo: Apply filters here into the buffer and then play it modified
                  mPlayer.write(mBuffer, 0, mBufferSize);         
                  //Log.v("MY AMP","ARA");
              }
  </code></pre>
  
  <p>And the inicialization this way:</p>
  
  <pre><code>// ==================== INITIALIZE ========================= //
  public void initialize(){
  
      mBufferSize = AudioRecord.getMinBufferSize(mHz, 
                  AudioFormat.CHANNEL_CONFIGURATION_MONO, 
                  AudioFormat.ENCODING_PCM_16BIT);
  
      mBufferSize2 = AudioTrack.getMinBufferSize(mHz, 
                  AudioFormat.CHANNEL_CONFIGURATION_MONO, 
                  AudioFormat.ENCODING_PCM_16BIT);
  
      mBuffer = new byte[mBufferSize];
  
      Log.v("MY AMP","Buffer size:" + mBufferSize);
  
      mRecorder = new AudioRecord(MediaRecorder.AudioSource.MIC, 
                  mHz,
                  AudioFormat.CHANNEL_CONFIGURATION_MONO,
                  AudioFormat.ENCODING_PCM_16BIT, 
                  mBufferSize);
  
      mPlayer = new AudioTrack(AudioManager.STREAM_MUSIC,
                  mHz,
                  AudioFormat.CHANNEL_CONFIGURATION_MONO,
                  AudioFormat.ENCODING_PCM_16BIT,
                  mBufferSize2, 
                  AudioTrack.MODE_STREAM);    
  
  }
  </code></pre>
  
  <p>do you know how to get a faster response? 
  Thanks!</p>