瀏覽代碼

fix formatting, remove warnings

richarddobson 2 年之前
父節點
當前提交
5fb6815ec5
共有 2 個文件被更改,包括 177 次插入179 次删除
  1. 5 7
      dev/filter/filters0.c
  2. 172 172
      dev/filter/main.c

+ 5 - 7
dev/filter/filters0.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1983-2013 Trevor Wishart and Composers Desktop Project Ltd
+ * Copyright (c) 1983-2023 Trevor Wishart and Composers Desktop Project Ltd
  * http://www.trevorwishart.co.uk
  * http://www.trevorwishart.co.uk
  * http://www.composersdesktop.com
  * http://www.composersdesktop.com
  *
  *
@@ -79,7 +79,7 @@ int filter_process(dataptr dz)
     int exit_status = FINISHED;
     int exit_status = FINISHED;
     int filter_tail = 0, tail_extend = 0, was_tail_extend = 0, bufspace;
     int filter_tail = 0, tail_extend = 0, was_tail_extend = 0, bufspace;
 // NEW MAY 2012
 // NEW MAY 2012
-    int do_norm = 0, chans = dz->infile->channels, sndendset = 0, gotend = 0;
+    int do_norm = 0, chans = dz->infile->channels, sndendset = 0;
     double inmaxsamp = 0.0, outmaxsamp = 0.0, maxsamp;
     double inmaxsamp = 0.0, outmaxsamp = 0.0, maxsamp;
     float *buf = dz->sampbuf[0];
     float *buf = dz->sampbuf[0];
     int n, m, k, sndend = 0;
     int n, m, k, sndend = 0;
@@ -88,11 +88,11 @@ int filter_process(dataptr dz)
     case(FLTBANKV):
     case(FLTBANKV):
         if(dz->vflag[2])
         if(dz->vflag[2])
             do_norm = 1;
             do_norm = 1;
-            break;
+        break;
     case(FLTBANKV2):
     case(FLTBANKV2):
         if(dz->vflag[1])
         if(dz->vflag[1])
             do_norm = 1;
             do_norm = 1;
-            break;
+        break;
     case(FLTBANKN):
     case(FLTBANKN):
         do_norm = 1;
         do_norm = 1;
         break;
         break;
@@ -244,7 +244,6 @@ int filter_process(dataptr dz)
         sndend      = 0;
         sndend      = 0;
         tail_extend = 0;
         tail_extend = 0;
         was_tail_extend = 0;
         was_tail_extend = 0;
-        gotend      = 0;
         fprintf(stdout,"INFO: Running filter.\n");
         fprintf(stdout,"INFO: Running filter.\n");
         fflush(stdout);
         fflush(stdout);
     }
     }
@@ -1294,7 +1293,7 @@ int my_modulus(int x,int y)
 
 
 int newfval2(double *fbrk,double *hbrk,dataptr dz)
 int newfval2(double *fbrk,double *hbrk,dataptr dz)
 {
 {
-    int n, m, k, z, timepoint, nextrow;
+    int n, m, k, timepoint, nextrow;
     int entrycnt = dz->iparam[FLT_ENTRYCNT];
     int entrycnt = dz->iparam[FLT_ENTRYCNT];
     int wordcnt  = dz->iparam[FLT_WORDCNT];
     int wordcnt  = dz->iparam[FLT_WORDCNT];
     int hentrycnt = dz->iparam[HRM_ENTRYCNT];
     int hentrycnt = dz->iparam[HRM_ENTRYCNT];
@@ -1368,7 +1367,6 @@ int newfval2(double *fbrk,double *hbrk,dataptr dz)
         }
         }
     }
     }
     for(k=0;k<dz->iparam[FLT_CNT];k+=dz->iparam[FLT_HARMCNT]) {
     for(k=0;k<dz->iparam[FLT_CNT];k+=dz->iparam[FLT_HARMCNT]) {
-        z = 0;
         for(m=0; m < dz->iparam[FLT_HARMCNT];m++) { /* calc vals for partials from basefrq vals */
         for(m=0; m < dz->iparam[FLT_HARMCNT];m++) { /* calc vals for partials from basefrq vals */
             dz->parray[FLT_INFRQ][k+m] = dz->parray[FLT_INFRQ][k] * dz->parray[HARM_FRQ_CALC][m];
             dz->parray[FLT_INFRQ][k+m] = dz->parray[FLT_INFRQ][k] * dz->parray[HARM_FRQ_CALC][m];
             dz->parray[FLT_INAMP][k+m] = dz->parray[FLT_INAMP][k] * dz->parray[HARM_AMP_CALC][m];
             dz->parray[FLT_INAMP][k+m] = dz->parray[FLT_INAMP][k] * dz->parray[HARM_AMP_CALC][m];

+ 172 - 172
dev/filter/main.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1983-2013 Trevor Wishart and Composers Desktop Project Ltd
+ * Copyright (c) 1983-2023 Trevor Wishart and Composers Desktop Project Ltd
  * http://www.trevorwishart.co.uk
  * http://www.trevorwishart.co.uk
  * http://www.composersdesktop.com
  * http://www.composersdesktop.com
  *
  *
@@ -49,9 +49,9 @@
 
 
 char errstr[2400];
 char errstr[2400];
 
 
-/*extern*/ int	sloom = 0;
+/*extern*/ int  sloom = 0;
 /* TW May 2001 */
 /* TW May 2001 */
-/*extern*/ int sloombatch = 0;	/*TW may 2001 */
+/*extern*/ int sloombatch = 0;  /*TW may 2001 */
 /*extern*/ int anal_infiles = 0;
 /*extern*/ int anal_infiles = 0;
 /*extern*/ int is_converted_to_stereo = -1;
 /*extern*/ int is_converted_to_stereo = -1;
 const char* cdp_version = "7.1.0";
 const char* cdp_version = "7.1.0";
@@ -63,190 +63,190 @@ static int setup_internal_arrays_and_array_pointers_for_lphp(dataptr dz);
 
 
 int main(int argc,char *argv[])
 int main(int argc,char *argv[])
 {
 {
-	int exit_status;
-/*	FILE *fp   = NULL;*/
-	dataptr dz = NULL;
-/*	char *special_data_string = NULL;*/
-	char **cmdline;
-	int  cmdlinecnt;
-	aplptr ap;
-	int *valid = NULL;
-	int is_launched = FALSE;
-	int  validcnt;
-
-	if(argc==2 && (strcmp(argv[1],"--version") == 0)) {
-		fprintf(stdout,"%s\n",cdp_version);
-		fflush(stdout);
-		return 0;
-	}
-						/* CHECK FOR SOUNDLOOM */
-	/* TW May 2001 */	
-	if((sloom = sound_loom_in_use(&argc,&argv)) > 1) {
-		sloom = 0;
-		sloombatch = 1;
-	}
-
-	if(!sloom) {
-		if((exit_status = allocate_and_initialise_validity_flags(&valid,&validcnt))<0) {
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-			return(FAILED);
-		}
-	}
-	if(sflinit("cdp")){
-		sfperror("cdp: initialisation\n");
-		return(FAILED);
-	}
-
-						  /* SET UP THE PRINCIPLE DATASTRUCTURE */
-	if((exit_status = establish_datastructure(&dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-
-	if(!sloom) {
-							  /* INITIAL CHECK OF CMDLINE DATA */
-		if((exit_status = make_initial_cmdline_check(&argc,&argv))<0) {
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-			return(FAILED);
-		}
-		cmdline    = argv;	/* GET PRE_DATA, ALLOCATE THE APPLICATION, CHECK FOR EXTRA INFILES */
-		cmdlinecnt = argc;
-		if((exit_status = get_process_and_mode_from_cmdline(&cmdlinecnt,&cmdline,dz))<0) {
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-			return(FAILED);
-		}		
-		if((exit_status = setup_particular_application(dz))<0) {
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-			return(FAILED);
-		}
-		if((exit_status = count_and_allocate_for_infiles(cmdlinecnt,cmdline,dz))<0) {
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-			return(FAILED);
-		}
-	} else {
-		if((exit_status = parse_tk_data(argc,argv,&cmdline,&cmdlinecnt,dz))<0) {  	/* includes setup_particular_application()      */
-			exit_status = print_messages_and_close_sndfiles(exit_status,is_launched,dz);/* and cmdlinelength check = sees extra-infiles */
-			return(exit_status);		 
-		}
-	}
-	ap = dz->application;
+    int exit_status;
+/*  FILE *fp   = NULL;*/
+    dataptr dz = NULL;
+/*  char *special_data_string = NULL;*/
+    char **cmdline;
+    int  cmdlinecnt;
+//    aplptr ap;
+    int *valid = NULL;
+    int is_launched = FALSE;
+    int  validcnt;
+
+    if(argc==2 && (strcmp(argv[1],"--version") == 0)) {
+        fprintf(stdout,"%s\n",cdp_version);
+        fflush(stdout);
+        return 0;
+    }
+                        /* CHECK FOR SOUNDLOOM */
+    /* TW May 2001 */   
+    if((sloom = sound_loom_in_use(&argc,&argv)) > 1) {
+        sloom = 0;
+        sloombatch = 1;
+    }
+
+    if(!sloom) {
+        if((exit_status = allocate_and_initialise_validity_flags(&valid,&validcnt))<0) {
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+            return(FAILED);
+        }
+    }
+    if(sflinit("cdp")){
+        sfperror("cdp: initialisation\n");
+        return(FAILED);
+    }
+
+                          /* SET UP THE PRINCIPLE DATASTRUCTURE */
+    if((exit_status = establish_datastructure(&dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+
+    if(!sloom) {
+                              /* INITIAL CHECK OF CMDLINE DATA */
+        if((exit_status = make_initial_cmdline_check(&argc,&argv))<0) {
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+            return(FAILED);
+        }
+        cmdline    = argv;  /* GET PRE_DATA, ALLOCATE THE APPLICATION, CHECK FOR EXTRA INFILES */
+        cmdlinecnt = argc;
+        if((exit_status = get_process_and_mode_from_cmdline(&cmdlinecnt,&cmdline,dz))<0) {
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+            return(FAILED);
+        }       
+        if((exit_status = setup_particular_application(dz))<0) {
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+            return(FAILED);
+        }
+        if((exit_status = count_and_allocate_for_infiles(cmdlinecnt,cmdline,dz))<0) {
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+            return(FAILED);
+        }
+    } else {
+        if((exit_status = parse_tk_data(argc,argv,&cmdline,&cmdlinecnt,dz))<0) {    /* includes setup_particular_application()      */
+            exit_status = print_messages_and_close_sndfiles(exit_status,is_launched,dz);/* and cmdlinelength check = sees extra-infiles */
+            return(exit_status);         
+        }
+    }
+//    ap = dz->application;
 
 
 /*********************************************************************************************************************
 /*********************************************************************************************************************
-	   cmdline[0]				 		  2 vals					   		  ACTIVE		 
-TK 		(infile) (more-infiles) (outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
-CMDLINE	(infile) (more-infiles) (outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY	  	POSSIBLY
-								 		  1 val
+       cmdline[0]                         2 vals                              ACTIVE         
+TK      (infile) (more-infiles) (outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
+CMDLINE (infile) (more-infiles) (outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY      POSSIBLY
+                                          1 val
 *********************************************************************************************************************/
 *********************************************************************************************************************/
 
 
-	if((exit_status = parse_infile_and_hone_type(cmdline[0],valid,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
+    if((exit_status = parse_infile_and_hone_type(cmdline[0],valid,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
 
 
-	if((exit_status = setup_param_ranges_and_defaults(dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
+    if((exit_status = setup_param_ranges_and_defaults(dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
 
 
-					/* OPEN FIRST INFILE AND STORE DATA, AND INFORMATION, APPROPRIATELY */
+                    /* OPEN FIRST INFILE AND STORE DATA, AND INFORMATION, APPROPRIATELY */
 
 
-	if(dz->input_data_type!=NO_FILE_AT_ALL) {
-		if((exit_status = open_first_infile(cmdline[0],dz))<0) {	
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);	
-			return(FAILED);
-		}
+    if(dz->input_data_type!=NO_FILE_AT_ALL) {
+        if((exit_status = open_first_infile(cmdline[0],dz))<0) {    
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);  
+            return(FAILED);
+        }
 //TW UPDATE
 //TW UPDATE
-		cmdlinecnt--;
-		cmdline++;
-	}
+        cmdlinecnt--;
+        cmdline++;
+    }
 // TW MULTICHAN 2010
 // TW MULTICHAN 2010
-	if(dz->process == LPHP) {
-		if((exit_status = setup_internal_arrays_and_array_pointers_for_lphp(dz))<0) {	
-			print_messages_and_close_sndfiles(exit_status,is_launched,dz);	
-			return(FAILED);
-		}
-	}
-	
+    if(dz->process == LPHP) {
+        if((exit_status = setup_internal_arrays_and_array_pointers_for_lphp(dz))<0) {   
+            print_messages_and_close_sndfiles(exit_status,is_launched,dz);  
+            return(FAILED);
+        }
+    }
+    
 /*********************************************************************************************************************
 /*********************************************************************************************************************
-		cmdline[0]				   2 vals				   			   ACTIVE		 
-TK 		(more-infiles) (outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
-CMDLINE	(more-infiles) (outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY		  POSSIBLY
-								   1 val
+        cmdline[0]                 2 vals                              ACTIVE        
+TK      (more-infiles) (outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
+CMDLINE (more-infiles) (outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY         POSSIBLY
+                                   1 val
 *********************************************************************************************************************/
 *********************************************************************************************************************/
 
 
-	if((exit_status = handle_extra_infiles(&cmdline,&cmdlinecnt,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);		
-		return(FAILED);
-	}
+    if((exit_status = handle_extra_infiles(&cmdline,&cmdlinecnt,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);      
+        return(FAILED);
+    }
 
 
 /*********************************************************************************************************************
 /*********************************************************************************************************************
-		cmdline[0]	  2					   			    ACTIVE		 
-TK 		(outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
-CMDLINE	(outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY		   POSSIBLY
-					  1
+        cmdline[0]    2                                 ACTIVE       
+TK      (outfile) (flag val) (formantsqksrch) (special) params  options   variant-params  flags
+CMDLINE (outfile) (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY         POSSIBLY
+                      1
 *********************************************************************************************************************/
 *********************************************************************************************************************/
 
 
-	if((exit_status = handle_outfile(&cmdlinecnt,&cmdline,is_launched,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
+    if((exit_status = handle_outfile(&cmdlinecnt,&cmdline,is_launched,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
 
 
 /****************************************************************************************
 /****************************************************************************************
-		cmdline[0]	  		   			       ACTIVE		 
-TK 		(flag val) (formantsqksrch) (special) params  options   variant-params  flags
-CMDLINE	(formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY		POSSIBLY
+        cmdline[0]                             ACTIVE        
+TK      (flag val) (formantsqksrch) (special) params  options   variant-params  flags
+CMDLINE (formants) (formantsqksrch) (special) params  POSSIBLY  POSSIBLY        POSSIBLY
 *****************************************************************************************/
 *****************************************************************************************/
 
 
-	if((exit_status = handle_formants(&cmdlinecnt,&cmdline,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	if((exit_status = handle_formant_quiksearch(&cmdlinecnt,&cmdline,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	if((exit_status = handle_special_data(&cmdlinecnt,&cmdline,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
+    if((exit_status = handle_formants(&cmdlinecnt,&cmdline,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    if((exit_status = handle_formant_quiksearch(&cmdlinecnt,&cmdline,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    if((exit_status = handle_special_data(&cmdlinecnt,&cmdline,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
  
  
 /****************************************************************************************
 /****************************************************************************************
-		cmdline[0]	  		   			    
-TK 		active_params  	options   		variant-params  flags
-CMDLINE	active_params  	POSSIBLY  		POSSIBLY		POSSIBLY
+        cmdline[0]                          
+TK      active_params   options         variant-params  flags
+CMDLINE active_params   POSSIBLY        POSSIBLY        POSSIBLY
 *****************************************************************************************/
 *****************************************************************************************/
 
 
-	if((exit_status = read_parameters_and_flags(&cmdline,&cmdlinecnt,dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-
-	if((exit_status = check_param_validity_and_consistency(dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-
- 	is_launched = TRUE;
-
-	if((exit_status = allocate_large_buffers(dz))<0){
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	if((exit_status = param_preprocess(dz))<0){
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	if((exit_status = groucho_process_file(dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	if((exit_status = complete_output(dz))<0) {
-		print_messages_and_close_sndfiles(exit_status,is_launched,dz);
-		return(FAILED);
-	}
-	exit_status = print_messages_and_close_sndfiles(FINISHED,is_launched,dz);
-	free(dz);
-	return(SUCCEEDED);
+    if((exit_status = read_parameters_and_flags(&cmdline,&cmdlinecnt,dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+
+    if((exit_status = check_param_validity_and_consistency(dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+
+    is_launched = TRUE;
+
+    if((exit_status = allocate_large_buffers(dz))<0){
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    if((exit_status = param_preprocess(dz))<0){
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    if((exit_status = groucho_process_file(dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    if((exit_status = complete_output(dz))<0) {
+        print_messages_and_close_sndfiles(exit_status,is_launched,dz);
+        return(FAILED);
+    }
+    exit_status = print_messages_and_close_sndfiles(FINISHED,is_launched,dz);
+    free(dz);
+    return(SUCCEEDED);
 }
 }
 
 
 // TW MULTICHAN 2010
 // TW MULTICHAN 2010
@@ -254,14 +254,14 @@ CMDLINE	active_params  	POSSIBLY  		POSSIBLY		POSSIBLY
 
 
 int setup_internal_arrays_and_array_pointers_for_lphp(dataptr dz)
 int setup_internal_arrays_and_array_pointers_for_lphp(dataptr dz)
 {
 {
-	int n;		 
-	dz->array_cnt = 3 + (FLT_LPHP_ARRAYS_PER_FILTER * dz->infile->channels); 
-	if((dz->parray  = (double **)malloc(dz->array_cnt * sizeof(double *)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for internal double arrays.\n");
-		return(MEMORY_ERROR);
-	}
-	for(n=0;n<dz->array_cnt;n++)
-		dz->parray[n] = NULL;
-	return(FINISHED);
+    int n;       
+    dz->array_cnt = 3 + (FLT_LPHP_ARRAYS_PER_FILTER * dz->infile->channels); 
+    if((dz->parray  = (double **)malloc(dz->array_cnt * sizeof(double *)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for internal double arrays.\n");
+        return(MEMORY_ERROR);
+    }
+    for(n=0;n<dz->array_cnt;n++)
+        dz->parray[n] = NULL;
+    return(FINISHED);
 }
 }