Reputation: 125
I am trying to obtain and represent the SPL of a a wav file previously recorded with the internal mic of my device. The problem is that the values that I am getting seem not to be logic at all, as I´m getting values over 100 db simply clapping my hands as you can see here:
(source: subirimagenes.com)
This is what I am doing:
Do you guys know what Im I doing wrong? I think the values should be around half of the ones obtained
Here is the piece of code:
protected void miThread() {
Thread t=new Thread() {
public void run(){
//Operaciones ope=new Operaciones();
double [] st =new double [arr.length];
int j=0;
try{
for (int i = 44; i < s; i+=2) {
// convert byte pair to int
double audioSample = (double) (array[i+1] << 8 | array[i] & 0xff)/ 32767.0;
arr[j]=audioSample; //double
n[j] = (Number)arr[j]; //Number
st[j]=10*Math.log10(Math.abs((audioSample/Math.pow(10, -12)))); //double
l[j]=(Number)(10*Math.log10(Math.abs((audioSample/Math.pow(10, -12))))); //Number
if(audioSample == 0.0 ){
if(j!=0){
l[j]=l[j-1];
st[j]=st[j-1];
}else{
l[j]=0.0;
st[j]=0.0;
}
}
j=j+1;}
min=Operaciones.minimum(arr);
max=Operaciones.maximum(arr);
min2=Operaciones.minimum(st);
max2=Operaciones.maximum(st);
}
catch (NullPointerException e){
e.printStackTrace();
}
handle.post(proceso);
} }; t.start();
}
final Runnable proceso=new Runnable(){
public void run(){
//plot.redraw();
//plot2.redraw();
Toast.makeText(Grafica.this,
"Ya se ha cargado todo el array", Toast.LENGTH_LONG).show();
}
};
Upvotes: 0
Views: 3142
Reputation: 13
Isnt SPL standing for sound pressure level compared to the absolute reference?. So the microphone is plugged into a 16bit precision port I think it
s ok. SNR should be around 60dB so you have around 44dB for voice interval. So when microphone receives any sound the signal should go up (around 104dB if I recall is for 16bit).
SPL=20log (Pascal/2e-5)
Upvotes: 1