title: Background noise while recording audio with Java/Bandpass filter as solution?
body: <p>so, the last days I've been playing arround with the Google speech API to perform simple voice recognition tasks. I got one upload script - working perfectly - uploading an .wav file and receiving the said words back. I also got a good microphone. The problem is:</p>
  
  <p>When listening to my microphone input from System Settings or from Audacity, there is no noise in the background. But as soon as I record with Java, my samples get inaccurate and impossible for Googles servers to parse. I already tried to smooth out the audio, with success on the result, but the servers can't process the sounds when the consonants like "T" or "K" are missing.</p>
  
  <p>So, now I would like to do a bandpass filter, to filter out the frequency spectrum I want (voice spectrum from about 100Hz to 600Hz). The problem is, I don't know where to start. I would like to add the filter to the following method:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>        static int spikesensitivity = 50;
       static int sens = 7;
       static byte smoothedValue = 0;
       static int smoothing = 2;
       public static byte[] removeNoise(byte[] b, TargetDataLine line ){ 
               
               byte[] returnThis = new byte[b.length];
  
               for( int i = 0; i &lt; b.length; i++){
                smoothedValue += (b[i] - smoothedValue) / smoothing;
                returnThis[i] = smoothedValue;
               }
                                               
               return returnThis;
       }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The TargetDataLines datarates are: 16000Hz, 8 bit, mono, PCM, 1 channel (1 byte per frame).</p>
  
  <p>Just in case someone experienced something similar: Why is audio recording in Java so bad? All my other programs (non-Java) seem to get better voice input than I can obtain using Java. The noise is always there, no matter what frequency or setup i choose - but as soon as I try the same settings in any other program, the noise is gone :/</p>
  
  <p>Thank you in advance for your time reading/replying to this :)</p>
  
  <p>Line opening snippet: <a href="http://pastebin.com/qtEyNmCe" rel="nofollow">http://pastebin.com/qtEyNmCe</a></p>