changeset 3:a6db7d8d6df4

change compile-time quiet control to runtime, and suppress all noisy output
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 15 Jun 2024 00:09:40 +0000
parents aa7cc4333d95
children a2529fec5442
files Makefile gsm_hr.c
diffstat 2 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri Jun 14 23:57:53 2024 +0000
+++ b/Makefile	Sat Jun 15 00:09:40 2024 +0000
@@ -1,5 +1,5 @@
 CC=	gcc
-CFLAGS=	-O2 -fno-builtin -DSILENT
+CFLAGS=	-O2 -fno-builtin
 PROG=	gsm_hr
 OBJS=	dtx.o err_conc.o globdefs.o gsm_hr.o homing.o host.o mathdp31.o \
 	mathhalf.o sp_dec.o sp_enc.o sp_frm.o sp_rom.o sp_sfrm.o vad.o
--- a/gsm_hr.c	Fri Jun 14 23:57:53 2024 +0000
+++ b/gsm_hr.c	Sat Jun 15 00:09:40 2024 +0000
@@ -100,6 +100,8 @@
   FILE  *pfileInFile,
         *pfileOutFile;
 
+  int quiet = 0;
+
 /*_________________________________________________________________________
  |                                                                         |
  |                              Executable Code                            |
@@ -163,6 +165,16 @@
     option = 0;
   else if (!strcmp(argv[1], "dec"))
     option = 1;
+  else if (!strcmp(argv[1], "enc-q"))
+  {
+    option = 0;
+    quiet = 1;
+  }
+  else if (!strcmp(argv[1], "dec-q"))
+  {
+    option = 1;
+    quiet = 1;
+  }
   else
   {
     printf("error in option selection\n");
@@ -206,6 +218,7 @@
     exit(1);
   }
 
+if (!quiet) {
   puts("\n\n");
   puts("   ****************************************");
   puts("   *                                      *");
@@ -241,7 +254,7 @@
 
   printf("input file:   %s\n", argv[2]);
   printf("output file:  %s\n\n", argv[3]);
-
+}
 
   switch (option)
   {
@@ -260,9 +273,8 @@
            giFrmCnt++)
       {
 
-#ifndef SILENT
-        printf("encoding frame %d \r", giFrmCnt);
-#endif
+        if (!quiet)
+          printf("encoding frame %d \r", giFrmCnt);
 
         if (encode(pfileInFile, pfileOutFile))
           iDoneFrm = 1;
@@ -271,7 +283,8 @@
       if (iDoneFrm)
         giFrmCnt--;
 
-      printf(" %d speech frames encoded\n", giFrmCnt - 1);
+      if (!quiet)
+        printf(" %d speech frames encoded\n", giFrmCnt - 1);
       break;
 
     case 1:                            /* decode */
@@ -289,9 +302,8 @@
            giFrmCnt++)
       {
 
-#ifndef SILENT
-        printf("decoding frame %d \r", giFrmCnt);
-#endif
+        if (!quiet)
+          printf("decoding frame %d \r", giFrmCnt);
 
         if (decode(pfileInFile, pfileOutFile))
           iDoneFrm = 1;
@@ -300,7 +312,8 @@
       if (iDoneFrm)
         giFrmCnt--;
 
-      printf(" %d speech frames decoded\n", giFrmCnt - 1);
+      if (!quiet)
+        printf(" %d speech frames decoded\n", giFrmCnt - 1);
       break;
   }