Some corrections to the logging switches.
[leqm-nrt.git] / leqm-nrt.c
index 03d4e5976e3ff181c84e259e106bc19631417ddb..a8a5ac32a933407f987f8e49e2f8a0abbbb1e709 100644 (file)
@@ -118,6 +118,9 @@ int main(int argc, const char ** argv)
        double * shorttermaveragedarray;
        int numbershortperiods;
        int parameterstate = 0;
+       int leqnw = 0;
+
+       char soundfilename[64];
        // This is a requirement of sndfile library, do not forget it.
 
        memset(&sfinfo, 0, sizeof(sfinfo));
@@ -141,7 +144,7 @@ int main(int argc, const char ** argv)
            return 1;
          }
          
-
+         strcpy(soundfilename, argv[in]);
             fileopenstate = 1;
             printf("Opened file: %s\n", argv[in]);
             printf("Sample rate: %d\n", sfinfo.samplerate);
@@ -161,11 +164,11 @@ int main(int argc, const char ** argv)
 
       if (strcmp(argv[in], "-chconfcal") == 0) {
        /* as the order of parameter is free I have to postpone 
-          the check for consistency with the number of channel.
+          the check for consistency with the number of channels.
           So first create a temporary array, whose number of element will be checked after 
           the parsing of the command line parameters is finished. 
           The calibration will be expressed in dB on the command line and converted to multiplier 
-          here so that it can be stored as a factor in the channelconcalvector.
+          here so that it can be stored as a factor in the channelconfcalvector.
        */
 
        in++;
@@ -206,14 +209,22 @@ int main(int argc, const char ** argv)
                      if (strcmp(argv[in], "-logleqm10") == 0) {
                leqm10 = 1;
             in++;
-            printf("Leq(M)10 data will be logged in the file leqm10.txt\n");
+            printf("Leq(M)10 data will be logged to the file leqm10.txt\n");
             continue;
        
       }
                                      if (strcmp(argv[in], "-logleqm") == 0) {
                leqmlog = 1;
             in++;
-            printf("Leq(M)10 data will be logged in the file leqmlog.txt\n");
+            printf("Leq(M) data will be logged to the file leqmlog.txt\n");
+            continue;
+       
+      }
+
+                                     if (strcmp(argv[in], "-leqnw") == 0) {
+               leqnw = 1;
+            in++;
+            printf("Leq(nW) - unweighted -  will be outputted.\n");
             continue;
        
       }
@@ -258,24 +269,25 @@ int main(int argc, const char ** argv)
 
 
     if (leqm10) {
-
-     leqm10logfile = fopen("leqm10.txt", "w");
+      char tempstring[128];
+      strcpy(tempstring, soundfilename);
+      strcat(tempstring, ".leqm10.txt");
+      leqm10logfile = fopen(tempstring, "w");
       if (leqm10logfile == NULL) {
        printf("Could not open file to write log leqm10 data!\n");
-       
       }
-      
     }
 
 
 
 
     if (leqmlog) {
-
-     leqmlogfile = fopen("leqmlog.txt", "w");
+      char tempstring[128];
+      strcpy(tempstring, soundfilename);
+      strcat(tempstring, ".leqmlog.txt");
+      leqmlogfile = fopen(tempstring, "w");
       if (leqmlogfile == NULL) {
-       printf("Could not open file to write log leqm data!\n");
-       
+       printf("Could not open file to write log leqm data!\n");        
       }
     }
     
@@ -470,7 +482,9 @@ int main(int argc, const char ** argv)
  // mean of scalar sum over duration
  
  meanoverduration(totsum);
+ if (leqnw) {
  printf("Leq(noW): %.4f\n", totsum->rms); // Leq(no Weighting)
+ }
  printf("Leq(M): %.4f\n", totsum->leqm);
 
   if(timing) {
@@ -868,10 +882,8 @@ int meanoverduration(struct Sum * oldsum) {
    oldsum->leqm = 20*log10(oldsum->cmean) + 110.600;//  
      // and 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 Dolby Tone (RMS) I think this is correct
-     // + 113.6191; //this value is obtained calibrating with a -20 dBFS Dolby Tone
    //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
-   //But this is only approximate as you should use a separate calibration according to the Dolby Format. Also for SW
-   //the tone should be 100Hz
+   //This is only approximate as you should use a separate calibration according to the Dolby Format. Also for SW the tone should be 100Hz (?)
 
 return 0;
 }