3 Replies Latest reply: Dec 21, 2011 9:30 AM by ptoye RSS

    Java graphic of silence

      I'm making an application that draws a graphic of the sound.
      When there is complete silence the TargetDataLine read method returns a value about 20.000.
      Why isn't this value 0 when there are no sounds? To be sure there is silence I remove the microphone.

      This is how I compute it:
        public int[] get_samples(byte audioData[]) {
            int samples[] = new int[audioData.length/2];
            int index = 0;
            for(Integer i=0;i<audioData.length;) {
                      int low = (int) audioData;
      int high = (int) audioData[i];
      int sample = (high << 8) + (low & 0x00ff);
      samples[index] = sample;
      return samples;

      Thank you

      Edited by: user10878887 on Dec 11, 2011 5:26 AM