0

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:

image
(source: subirimagenes.com)

This is what I am doing:

  • First of all, as the wav file is saved in 16-bit PCM, I operate with its bytes to have an unique double value normalized between [-1,1] ( I don´t operate with the first 44 bytes as it is the wav header).
  • Then, following this equation SPL=10*log(audioSample/Iref) I obtain each of the desired sound levels (being Iref=10^-12).
  • At the end I calculate the max and min values to set the margins of the plot.

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();
            }
        };  
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
paviflo
  • 105
  • 2
  • 13
  • To convert to dBSPL - I think you want to first convert to Pascals by multiplication - perhaps by lref. Next you need to convert from pascals to dBSPL where `dBSPL = 20*log10(Pa/2e-5)`. It is very unusual and not very useful to look plot a time domain waveform in any dB unit. You probably would be better off plotting it in Pascals. – jaket Jun 09 '14 at 01:05
  • Also, I'm a bit suspicious of your 10e-12 number for lref. Is that sensitivity of your microphone? – jaket Jun 09 '14 at 01:07
  • Hi jaket, thank you for answering, as I´ve read in several sources on internet, the sound pressure level Lp=20log(Pa/2e-5) is equal to the sound intensity level Li=10log(I/10e-12), and in this case I´m using the second formula ( and therefore, its Iref). What I don´t really know is what audioSamples is giving me, the Pressure or the Intensity? and how can I convert it to Pascals? I´m a little bit confused with this – paviflo Jun 09 '14 at 11:24
  • audioSamples are instantaneous values representing a fraction of full scale (FFS) of the input to the converter. What you need to know to convert to Pascals is the sensitivity of the mic. In other words, how many Pascals does it take to produce full scale audioSamples. The way to characterize this is by measuring the RMS level of the FFS input while a mic calibrator is hooked up to the mic. The calibrator will produce a tone at 94dBSPL so you can compute backwards to determine the scaling factor in FFS per Pascal. It's also possible the datasheet for the mic has it spec'd. – jaket Jun 09 '14 at 23:20

1 Answers1

1

Isnt SPL standing for sound pressure level compared to the absolute reference?. So the microphone is plugged into a 16bit precision port I think its 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)