title: recording timestamps of audio samples while recording using a java applicatin
body: <p>I've made a java audio recorder and would like to know the system timestamp of each audio sample that I record.  I am recording for 1sec at 44.1KHz.  For each sample (theres 441000) I would like to record the time (system timestamp) that the microphone detected the sound.  How would I do this, if it is possible?  I would like an accuracy of +-1ms.</p>
  
  <p>this is a snap shot of the code im using.</p>
  
  <pre><code>AudioFormat format = new AudioFormat(44100f, 8, 1, true, false);
  DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
  TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
  line.open(format);
  line.start();
  byte[] buff = new byte[line.getBufferSize()];
  while(recording){
      int index = line.read(buff, 0, buff.length);
      out.write(buff, 0, index);
  }
  line.stop();
  line.close();
  byte[] audio = out.toByteArray();
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Edit</p>
  
  <p>Getting a timestamp ever other sample, or even every 10 samples would be ok as long as its accurate.  Also i meant 44100* samples.</p>