title: Android AudioTrack generate buffer with one frequency in one ear and a second frequency in the other ear
body: <p>I'm generating a tone on android</p>
  
  <pre><code>public void toneer(){
      final int duration = 10; // duration of sound
      final int sampleRate = 22050; // Hz (maximum frequency is 7902.13Hz (B8))
      final int numSamples = duration * sampleRate;
      final double samples[] = new double[numSamples];
      final short buffer[] = new short[numSamples];
      for (int i = 0; i &lt; numSamples; ++i)
      {
  
          samples[i] = Math.sin(2 * Math.PI * i / (sampleRate / 440)); // Sine wave
          buffer[i] = (short) (samples[i] * Short.MAX_VALUE);  // Higher amplitude increases volume
      }
  
  
      AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
              sampleRate, AudioFormat.CHANNEL_OUT_MONO,
              AudioFormat.ENCODING_PCM_16BIT, buffer.length,
              AudioTrack.MODE_STATIC);
      audioTrack.write(buffer,  0, buffer.length);
      audioTrack.play();
  }
  </code></pre>
  
  <p>I have seen some places discussing that <a href="https://stackoverflow.com/questions/31703976/play-2-different-audio-streams-on-left-and-right-speaker">is possible to have the buffer just sound on the left of the right?</a></p>
  
  <p>My question is: how to generate a "binaural" beat, one frequency in one ear, while another tone is played on the second ear?</p>