title: Java audio input inconsistencies
body: <p>I've been working on a guitar tuner Java application for quite some time and have finally managed to get the pitch (fundamental frequency) detection to accurately determine the fundamental frequency of the input using an FFT and the Harmonic Product Spectrum. This works perfectly when I use my MacBook Pro's default microphone, despite the fact that the signal is a little noisy, but I would ideally like to use my external USB audio sound interface (Lexicon Lambda) with an electric guitar directly plugged in. I have tried this with the exact same code that works perfectly for the mic input, but the pitch detected is different. Here are my results of fundamentals detected for each string (the guitar is in tune already).</p>
  
  <p>Sample rate = 8000<br />
  Samples taken = 16000<br />
  Frequency resolution = 0.5Hz</p>
  
  <p>E - Mic: 82.5Hz - Lexicon Lambda: 124.5Hz<br />
  A - Mic: 110.0Hz - Lexicon Lambda: 165.5Hz<br />
  D - Mic: 147.0Hz - Lexicon Lambda: 221.5Hz<br />
  G - Mic: 196.0Hz - Lexicon Lambda: 293.5Hz<br />
  B - Mic: 247.0Hz - Lexicon Lambda: 371.0Hz<br />
  E - Mic: 329.5Hz - Lexicon Lambda: 495.0Hz</p>
  
  <p>I have messed around a bit with these numbers and it seems that the result found using the Lexicon Lambda is generally about 1.5 times the size of the accurate result. But rather than just adding this extra calculation to get to the right number I would like to make it so that both methods of obtaining audio data return accurate results.</p>
  
  <p>Does anyone have any idea what the cause of this inconsistency might be?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So I am pretty sure that the problem is due to the Lambda using a bit-depth of 24 while my program (and the mic input) works with a bit-depth of 16. Rather than just changing it to deal with 24-bit data, does anyone know of a way to detect the available bit-depth of the current audio device?</p>
  
  <p>Using the Lambda is the priority, since the signal is less noisy; however, I have just been trying to get things to work with a bit depth of 24 specified, and I get the IllegalArgumentException "No line matching interface TargetDataLine supporting format PCM_SIGNED 8000.0 Hz, 24 bit, mono, 3 bytes/frame, little-endian is supported." I tried using 44.1kHz as well and I get the same error, which suggests the Lambda isn't actually working with 24-bit audio or perhaps there is another issue. Does anyone have any experience working with 24-bit audio in Java Sound? It seems like there might be more to consider than just changing the bit-depth in order to make this work.</p>
  
  <p>Thanks</p>