get Microphone input level (amplitude) live
817082Nov 21 2010 — edited Nov 22 2010Hi
I'm working on a VoIP application, which has big problems with its echo... (mic->otherusers speakers->his mic->my speakers... i thing you know this szenario...)
I have now the idea to block my partners microphone while i'm speaking, and vice-versa - first of all i know thats not the best idea- since i know that on skype or other VOIP applications echo cancellation works quite well...
but i don' have the know-how how to do that with JAVA-Sound-API (targetdataline and sourcedatalines...)
the problem is, that the program needs to recognize if a person is speaking (to block the other's mic)... i found a VolumeRMS code in this forum (but it seems only to work fine with 8 Bit audio data - and i'm using 16 for better speech quality - the source for this was:
public double volumeRMS(double[] raw) {
double sum = 0d;
if (raw.length==0) {
return sum;
} else {
for (int ii=0; ii<raw.length; ii++) {
sum += raw[ii];
}
}
double average = sum/raw.length;
double[] meanSquare = new double[raw.length];
double sumMeanSquare = 0d;
for (int ii=0; ii<raw.length; ii++) {
sumMeanSquare += Math.pow(raw[ii]-average,2d);
meanSquare[ii] = sumMeanSquare;
}
double averageMeanSquare = sumMeanSquare/raw.length;
double rootMeanSquare = Math.pow(averageMeanSquare,0.5d);
return rootMeanSquare;
}
There are (i think so) one bug in this code:
its maximum amplitude is at about 0-60 (not 100)
the question is now, how can the program know when someone is speaking? (next to all the background-noise in my room)..
like a "isSomeBodySpeaking(soundbuffer[])" method?
or are there any better ideas to deal with echo-cancellation?
Can anybody help?