comparison gsm_hr.c @ 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 9008dbc8ca74
children
comparison
equal deleted inserted replaced
2:aa7cc4333d95 3:a6db7d8d6df4
97 option, 97 option,
98 i; 98 i;
99 99
100 FILE *pfileInFile, 100 FILE *pfileInFile,
101 *pfileOutFile; 101 *pfileOutFile;
102
103 int quiet = 0;
102 104
103 /*_________________________________________________________________________ 105 /*_________________________________________________________________________
104 | | 106 | |
105 | Executable Code | 107 | Executable Code |
106 |_________________________________________________________________________| 108 |_________________________________________________________________________|
161 163
162 if (!strcmp(argv[1], "enc")) 164 if (!strcmp(argv[1], "enc"))
163 option = 0; 165 option = 0;
164 else if (!strcmp(argv[1], "dec")) 166 else if (!strcmp(argv[1], "dec"))
165 option = 1; 167 option = 1;
168 else if (!strcmp(argv[1], "enc-q"))
169 {
170 option = 0;
171 quiet = 1;
172 }
173 else if (!strcmp(argv[1], "dec-q"))
174 {
175 option = 1;
176 quiet = 1;
177 }
166 else 178 else
167 { 179 {
168 printf("error in option selection\n"); 180 printf("error in option selection\n");
169 printf(" Your entry : %s \n", argv[1]); 181 printf(" Your entry : %s \n", argv[1]);
170 printf("\n\nUsage:\n\n"); 182 printf("\n\nUsage:\n\n");
204 { 216 {
205 printf("error: can not open file %s\n", argv[3]); 217 printf("error: can not open file %s\n", argv[3]);
206 exit(1); 218 exit(1);
207 } 219 }
208 220
221 if (!quiet) {
209 puts("\n\n"); 222 puts("\n\n");
210 puts(" ****************************************"); 223 puts(" ****************************************");
211 puts(" * *"); 224 puts(" * *");
212 puts(" * GSM Half-Rate Speech Coder *"); 225 puts(" * GSM Half-Rate Speech Coder *");
213 puts(" * *"); 226 puts(" * *");
239 else 252 else
240 printf("DTX mode: disabled\n"); 253 printf("DTX mode: disabled\n");
241 254
242 printf("input file: %s\n", argv[2]); 255 printf("input file: %s\n", argv[2]);
243 printf("output file: %s\n\n", argv[3]); 256 printf("output file: %s\n\n", argv[3]);
244 257 }
245 258
246 switch (option) 259 switch (option)
247 { 260 {
248 case 0: /* encode */ 261 case 0: /* encode */
249 262
258 for (giFrmCnt = 1, iDoneFrm = 0; 271 for (giFrmCnt = 1, iDoneFrm = 0;
259 !iDoneFrm && giFrmCnt <= iMaxNumFrms; 272 !iDoneFrm && giFrmCnt <= iMaxNumFrms;
260 giFrmCnt++) 273 giFrmCnt++)
261 { 274 {
262 275
263 #ifndef SILENT 276 if (!quiet)
264 printf("encoding frame %d \r", giFrmCnt); 277 printf("encoding frame %d \r", giFrmCnt);
265 #endif
266 278
267 if (encode(pfileInFile, pfileOutFile)) 279 if (encode(pfileInFile, pfileOutFile))
268 iDoneFrm = 1; 280 iDoneFrm = 1;
269 } 281 }
270 282
271 if (iDoneFrm) 283 if (iDoneFrm)
272 giFrmCnt--; 284 giFrmCnt--;
273 285
274 printf(" %d speech frames encoded\n", giFrmCnt - 1); 286 if (!quiet)
287 printf(" %d speech frames encoded\n", giFrmCnt - 1);
275 break; 288 break;
276 289
277 case 1: /* decode */ 290 case 1: /* decode */
278 291
279 /* start the decoder and receive DTX in the home state */ 292 /* start the decoder and receive DTX in the home state */
287 for (giFrmCnt = 1, iDoneFrm = 0; 300 for (giFrmCnt = 1, iDoneFrm = 0;
288 !iDoneFrm && giFrmCnt <= iMaxNumFrms; 301 !iDoneFrm && giFrmCnt <= iMaxNumFrms;
289 giFrmCnt++) 302 giFrmCnt++)
290 { 303 {
291 304
292 #ifndef SILENT 305 if (!quiet)
293 printf("decoding frame %d \r", giFrmCnt); 306 printf("decoding frame %d \r", giFrmCnt);
294 #endif
295 307
296 if (decode(pfileInFile, pfileOutFile)) 308 if (decode(pfileInFile, pfileOutFile))
297 iDoneFrm = 1; 309 iDoneFrm = 1;
298 } 310 }
299 311
300 if (iDoneFrm) 312 if (iDoneFrm)
301 giFrmCnt--; 313 giFrmCnt--;
302 314
303 printf(" %d speech frames decoded\n", giFrmCnt - 1); 315 if (!quiet)
316 printf(" %d speech frames decoded\n", giFrmCnt - 1);
304 break; 317 break;
305 } 318 }
306 319
307 fclose(pfileInFile); 320 fclose(pfileInFile);
308 fclose(pfileOutFile); 321 fclose(pfileOutFile);