This discussion is archived
3 Replies Latest reply: Dec 21, 2011 7:30 AM by ptoye RSS

Java graphic of silence

user10878887 Newbie
Currently Being Moderated
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;
i++;
int high = (int) audioData[i];
i++;
int sample = (high << 8) + (low & 0x00ff);
samples[index] = sample;
index++;
}
return samples;
}


Thank you

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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points