From: Luca Trisciani Date: Fri, 22 Mar 2019 10:30:57 +0000 (+0100) Subject: Comment on the calculation of final offset X-Git-Tag: v0.0.1~72 X-Git-Url: https://git.carlh.net/gitweb/?p=leqm-nrt.git;a=commitdiff_plain Comment on the calculation of final offset --- diff --git a/src/leqm-nrt.c b/src/leqm-nrt.c index efc89a1..d36e0e0 100644 --- a/src/leqm-nrt.c +++ b/src/leqm-nrt.c @@ -910,11 +910,18 @@ int sumsamples(struct Sum * ts, double * inputsamples, double * cinputsamples, i int meanoverduration(struct Sum * oldsum) { oldsum->mean = pow(oldsum->sum / ((double) oldsum->nsamples), 0.500); oldsum->cmean = pow(oldsum->csum / ((double) oldsum->nsamples), 0.500); - oldsum->rms = 20*log10(oldsum->mean) + 108.0851; - oldsum->leqm = 20*log10(oldsum->cmean) + 108.0851;// - //This must be right because M filter is -5.6 @ 1k Hz that is -25.6 dBFS and to have 85.0 as reference level we must add 25.56 + 85.00 that is 110.6 dB. - //this value is obtained calibrating with a -20 dBFS. - + oldsum->rms = 20*log10(oldsum->mean) + 108.010299957; + oldsum->leqm = 20*log10(oldsum->cmean) + 108.010299957;// + + /* +How the final offset is calculated without reference to a test tone: +P0 is the SPL reference 20 uPa +Reference SPL is RMS ! So 85 SPL over 20 uPa is 10^4.25 x 0.000020 = 0.355655882 Pa (RMS), +but Peak value is 0.355655882 x sqr(2) = 0.502973372 that is 20 x log ( 0.502973372 / 0.000020) = 88.010299957 +To that one has to add the 20 dB offset of the reference -20dBFS: 88.010299957 + 20.00 = 108.010299957 + */ + /*But ISO 21727:2004(E) ask for a reference level "measured using an average responding meter". So reference level is not 0.707, but 0.637 = 2/pi + */ return 0; } @@ -937,7 +944,7 @@ void logleqm(FILE * filehandle, double featuretimesec, struct Sum * oldsum) { } void logleqm10(FILE * filehandle, double featuretimesec, double longaverage) { - double leqm10 = 20*log10(pow(longaverage, 0.500)) + 108.0851; + double leqm10 = 20*log10(pow(longaverage, 0.500)) + 108.010299957; fprintf(filehandle, "%.4f", featuretimesec); fprintf(filehandle, "\t"); fprintf(filehandle, "%.4f\n", leqm10);