瀏覽代碼

remove warnings, update copyright date

richarddobson 2 年之前
父節點
當前提交
a262f3d135
共有 10 個文件被更改,包括 4886 次插入4890 次删除
  1. 764 764
      dev/standalone/freeze.c
  2. 190 191
      dev/stretch/main.c
  3. 192 193
      dev/submix/main.c
  4. 399 400
      dev/submix/mixshuf0.c
  5. 999 999
      dev/submix/mixshuf1.c
  6. 290 290
      dev/submix/mixshuf2.c
  7. 550 551
      dev/submix/newmix0.c
  8. 479 479
      dev/submix/newmix1.c
  9. 568 568
      dev/submix/setupmix.c
  10. 455 455
      dev/submix/syncatt.c

File diff suppressed because it is too large
+ 764 - 764
dev/standalone/freeze.c


+ 190 - 191
dev/stretch/main.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -44,7 +44,7 @@
 
 
 char errstr[2400];
 char errstr[2400];
 
 
-/*extern*/ int	sloom = 0;
+/*extern*/ int  sloom = 0;
 /*extern*/ int sloombatch = 0;
 /*extern*/ int sloombatch = 0;
 /*extern*/ int anal_infiles = 1;
 /*extern*/ int anal_infiles = 1;
 /*extern*/ int is_converted_to_stereo = -1;
 /*extern*/ int is_converted_to_stereo = -1;
@@ -54,181 +54,180 @@ const char* cdp_version = "7.1.0";
 
 
 int main(int argc,char *argv[])
 int main(int argc,char *argv[])
 {
 {
-	int exit_status;
-	dataptr dz = 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 */
-	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
-*********************************************************************************************************************/
-
-	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);
-	}
-
-					/* 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);
-		}
-//TW UPDATE
-		cmdlinecnt--;
-		cmdline++;
-	}
-
-/*********************************************************************************************************************
-		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);
-	}
-
-/*********************************************************************************************************************
-		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);
-	}
-
-/****************************************************************************************
-		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);
-	}
- 
-/****************************************************************************************
-		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 = spec_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);
+    int exit_status;
+    dataptr dz = 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 */
+    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
+    *********************************************************************************************************************/
+
+    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);
+    }
+
+    /* 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);
+        }
+        //TW UPDATE
+        cmdlinecnt--;
+        cmdline++;
+    }
+
+    /*********************************************************************************************************************
+                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);
+    }
+
+    /*********************************************************************************************************************
+                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);
+    }
+
+    /****************************************************************************************
+                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);
+    }
+
+    /****************************************************************************************
+                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 = spec_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);
 }
 }
-

+ 192 - 193
dev/submix/main.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -45,7 +45,7 @@
 
 
 char errstr[2400];
 char errstr[2400];
 
 
-int	sloom = 0;
+int     sloom = 0;
 int sloombatch = 0;
 int sloombatch = 0;
 
 
 int anal_infiles = 0;
 int anal_infiles = 0;
@@ -56,183 +56,182 @@ const char* cdp_version = "7.1.0";
 
 
 int main(int argc,char *argv[])
 int main(int argc,char *argv[])
 {
 {
-	int exit_status;
-	dataptr dz = 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 */
-	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
-*********************************************************************************************************************/
-
-	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);
-	}
-
-					/* 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);
-		}
-//TW UPDATE
-		cmdlinecnt--;
-		cmdline++;
-	}
-
-/*********************************************************************************************************************
-		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);
-	}
-
-/*********************************************************************************************************************
-		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(dz->process_type != SCREEN_MESSAGE) {
-		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
-*****************************************************************************************/
-
-	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
-*****************************************************************************************/
-
-	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);
+    int exit_status;
+    dataptr dz = 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 */
+    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
+    *********************************************************************************************************************/
+
+    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);
+    }
+
+    /* 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);
+        }
+        //TW UPDATE
+        cmdlinecnt--;
+        cmdline++;
+    }
+
+    /*********************************************************************************************************************
+                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);
+    }
+
+    /*********************************************************************************************************************
+                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(dz->process_type != SCREEN_MESSAGE) {
+        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
+    *****************************************************************************************/
+
+    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
+    *****************************************************************************************/
+
+    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);
 }
 }
-

+ 399 - 400
dev/submix/mixshuf0.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -51,233 +51,233 @@ static int  investigate_timings(double *duration,double *min_time,dataptr dz);
 
 
 int mix_shufl(dataptr dz)
 int mix_shufl(dataptr dz)
 {
 {
-	switch(dz->mode) {
-	case(MSH_OMIT_ALT):
-	case(MSH_OMIT):				return do_time_manip(dz);
-
-	case(MSH_DUPLICATE):
-	case(MSH_DUPL_AND_RENAME):	return do_time_and_name_copy(dz);
-
-	case(MSH_SCATTER):			return randomise_names(dz);
-	case(MSH_REVERSE_N):		return do_name_reverse(dz);
-	case(MSH_FIXED_N):			return do_name_freeze(dz);
-	default:
-		sprintf(errstr,"Unknown mode in mix_shufl()\n");
-		return(PROGRAM_ERROR);
-	}
-	return(FINISHED);	/* NOTREACHED */
+    switch(dz->mode) {
+    case(MSH_OMIT_ALT):
+    case(MSH_OMIT):                         return do_time_manip(dz);
+
+    case(MSH_DUPLICATE):
+    case(MSH_DUPL_AND_RENAME):      return do_time_and_name_copy(dz);
+
+    case(MSH_SCATTER):                      return randomise_names(dz);
+    case(MSH_REVERSE_N):            return do_name_reverse(dz);
+    case(MSH_FIXED_N):                      return do_name_freeze(dz);
+    default:
+        sprintf(errstr,"Unknown mode in mix_shufl()\n");
+        return(PROGRAM_ERROR);
+    }
+    return(FINISHED);       /* NOTREACHED */
 }
 }
 
 
 /************************* MIX_TIMEWARP ******************************/
 /************************* MIX_TIMEWARP ******************************/
 
 
 int mix_timewarp(dataptr dz)
 int mix_timewarp(dataptr dz)
 {
 {
-	switch(dz->mode) {
-	case(MTW_REVERSE_NT):	return do_name_and_time_reverse(dz);
-	case(MTW_FREEZE_NT): 	return do_name_and_time_freeze(dz);
-
-	case(MTW_REVERSE_T):	case(MTW_FREEZE_T):		case(MTW_SCATTER):		case(MTW_DOMINO):
-	case(MTW_CREATE_TG_1):	case(MTW_CREATE_TG_2):	case(MTW_CREATE_TG_3):	case(MTW_CREATE_TG_4):
-	case(MTW_ENLARGE_TG_1):	case(MTW_ENLARGE_TG_2):	case(MTW_ENLARGE_TG_3):	case(MTW_ENLARGE_TG_4):
-	case(MTW_ADD_TO_TG):	case(MTW_TIMESORT):
-		return do_time_manip(dz);
-	default:
-		sprintf(errstr,"Unknown mode in mix_timewarp()\n");
-		return(PROGRAM_ERROR);
-	}
-	return(FINISHED);	/* NOTREACHED */
+    switch(dz->mode) {
+    case(MTW_REVERSE_NT):   return do_name_and_time_reverse(dz);
+    case(MTW_FREEZE_NT):    return do_name_and_time_freeze(dz);
+
+    case(MTW_REVERSE_T):    case(MTW_FREEZE_T):             case(MTW_SCATTER):              case(MTW_DOMINO):
+    case(MTW_CREATE_TG_1):  case(MTW_CREATE_TG_2):  case(MTW_CREATE_TG_3):  case(MTW_CREATE_TG_4):
+    case(MTW_ENLARGE_TG_1): case(MTW_ENLARGE_TG_2): case(MTW_ENLARGE_TG_3): case(MTW_ENLARGE_TG_4):
+    case(MTW_ADD_TO_TG):    case(MTW_TIMESORT):
+        return do_time_manip(dz);
+    default:
+        sprintf(errstr,"Unknown mode in mix_timewarp()\n");
+        return(PROGRAM_ERROR);
+    }
+    return(FINISHED);       /* NOTREACHED */
 }
 }
 
 
 /************************* MIX_SPACEWARP ******************************/
 /************************* MIX_SPACEWARP ******************************/
 
 
 int mix_spacewarp(dataptr dz)
 int mix_spacewarp(dataptr dz)
 {
 {
-	int    exit_status;
-	int   n, total_words;
-	int    is_even = TRUE;
-	double position = 0.0;
-	int    *maxwordsize;
-	double duration = 0.0, min_time = 0.0, *timestor = NULL;
-	double spacerange = 0.0, leftedge = 0.0;
-	switch(dz->mode) {
-	case(MSW_TWISTALL):
-	case(MSW_TWISTONE):
-		return mix_twisted(dz);
-	case(MSW_LEFTWARDS):
-	case(MSW_RIGHTWARDS):
-		if((exit_status = investigate_timings(&duration,&min_time,dz))<0)
-			return(exit_status);
-		timestor = dz->parray[MSW_TIMESTOR];
-		/* fall thro */
-	case(MSW_RANDOM):
-	case(MSW_RANDOM_ALT):
-		spacerange = fabs(dz->param[MSW_POS2] - dz->param[MSW_POS1]);
-		leftedge   = min(dz->param[MSW_POS1],dz->param[MSW_POS2]);
-		break;
-	case(MSW_NARROWED):	
-	case(MSW_FIXED):	
-		break;
-	default:
-		sprintf(errstr,"Unknown mode in mix_spacewarp()\n");
-		return(PROGRAM_ERROR);
-	}
-	total_words = 0;
-	for(n=0;n<dz->iparam[MSH_STARTLINE];n++)
-		total_words += dz->wordcnt[n];
-	for(n=dz->iparam[MSH_STARTLINE];n<dz->iparam[MSH_ENDLINE];n++) {
-		switch(dz->mode) {
-		case(MSW_NARROWED):	
-			if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],dz->param[MSW_NARROWING],dz))<0)
-				return(exit_status);
-			break;
-		case(MSW_FIXED):	
-			if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],dz->param[MSW_POS1],dz))<0)
-				return(exit_status);
-			break;
-		default:
-			switch(dz->mode) {
-			case(MSW_RANDOM):
-				position  = (drand48() * POSITIONS)/POSITIONS;
-				break;
-			case(MSW_RANDOM_ALT):
-				switch(is_even) {
-				case(TRUE):	position = (drand48() * HALF_POSTNS)/POSITIONS; 				break;	/* Force Left */	
-				case(FALSE):position = (POSITIONS - (drand48() * HALF_POSTNS))/POSITIONS;	break;	/* Force Right */	
-				}
-				is_even = !is_even;
-				break;
-			case(MSW_LEFTWARDS):
-//TW UPDATE
-				if(duration > FLTERR)
-					position = (timestor[n] - min_time)/duration;
-				else {
-					sprintf(errstr,"Files do not Progress in Time : Hence cannot MOVE Leftwards\n");
-					return(USER_ERROR);
-				}
-				position = 1.0 - position;
-				break;
-			case(MSW_RIGHTWARDS):
-//TW UPDATE
-				if(duration > FLTERR)
-					position  = (timestor[n] - min_time)/duration;
-				else {
-					sprintf(errstr,"Files do not Progress in Time : Hence cannot MOVE Rightwards\n");
-					return(USER_ERROR);
-				}
-				break;
-			}
-			position *= spacerange;
-			position += leftedge;
-			if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],position,dz))<0)
-				return(exit_status);
-			break;
-		}
-		total_words += dz->wordcnt[n];
-	}
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
-		return(exit_status);
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
-		return(exit_status);
-	free(maxwordsize);
-	return(FINISHED);
+    int    exit_status;
+    int   n, total_words;
+    int    is_even = TRUE;
+    double position = 0.0;
+    int    *maxwordsize;
+    double duration = 0.0, min_time = 0.0, *timestor = NULL;
+    double spacerange = 0.0, leftedge = 0.0;
+    switch(dz->mode) {
+    case(MSW_TWISTALL):
+    case(MSW_TWISTONE):
+        return mix_twisted(dz);
+    case(MSW_LEFTWARDS):
+    case(MSW_RIGHTWARDS):
+        if((exit_status = investigate_timings(&duration,&min_time,dz))<0)
+            return(exit_status);
+        timestor = dz->parray[MSW_TIMESTOR];
+        /* fall thro */
+    case(MSW_RANDOM):
+    case(MSW_RANDOM_ALT):
+        spacerange = fabs(dz->param[MSW_POS2] - dz->param[MSW_POS1]);
+        leftedge   = min(dz->param[MSW_POS1],dz->param[MSW_POS2]);
+        break;
+    case(MSW_NARROWED):
+    case(MSW_FIXED):
+        break;
+    default:
+        sprintf(errstr,"Unknown mode in mix_spacewarp()\n");
+        return(PROGRAM_ERROR);
+    }
+    total_words = 0;
+    for(n=0;n<dz->iparam[MSH_STARTLINE];n++)
+        total_words += dz->wordcnt[n];
+    for(n=dz->iparam[MSH_STARTLINE];n<dz->iparam[MSH_ENDLINE];n++) {
+        switch(dz->mode) {
+        case(MSW_NARROWED):
+            if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],dz->param[MSW_NARROWING],dz))<0)
+                return(exit_status);
+            break;
+        case(MSW_FIXED):
+            if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],dz->param[MSW_POS1],dz))<0)
+                return(exit_status);
+            break;
+        default:
+            switch(dz->mode) {
+            case(MSW_RANDOM):
+                position  = (drand48() * POSITIONS)/POSITIONS;
+                break;
+            case(MSW_RANDOM_ALT):
+                switch(is_even) {
+                case(TRUE):     position = (drand48() * HALF_POSTNS)/POSITIONS;                                 break;  /* Force Left */
+                case(FALSE):position = (POSITIONS - (drand48() * HALF_POSTNS))/POSITIONS;       break;  /* Force Right */
+                }
+                is_even = !is_even;
+                break;
+            case(MSW_LEFTWARDS):
+                //TW UPDATE
+                if(duration > FLTERR)
+                    position = (timestor[n] - min_time)/duration;
+                else {
+                    sprintf(errstr,"Files do not Progress in Time : Hence cannot MOVE Leftwards\n");
+                    return(USER_ERROR);
+                }
+                position = 1.0 - position;
+                break;
+            case(MSW_RIGHTWARDS):
+                //TW UPDATE
+                if(duration > FLTERR)
+                    position  = (timestor[n] - min_time)/duration;
+                else {
+                    sprintf(errstr,"Files do not Progress in Time : Hence cannot MOVE Rightwards\n");
+                    return(USER_ERROR);
+                }
+                break;
+            }
+            position *= spacerange;
+            position += leftedge;
+            if((exit_status = adjust_stereo(n,total_words,dz->wordcnt[n],position,dz))<0)
+                return(exit_status);
+            break;
+        }
+        total_words += dz->wordcnt[n];
+    }
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
+        return(exit_status);
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
+        return(exit_status);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /*************************** GET_TIMES ***************************/
 /*************************** GET_TIMES ***************************/
 
 
 int get_times(double *timestor,dataptr dz)
 int get_times(double *timestor,dataptr dz)
 {
 {
-	int n, timeloc;
-	int total_wordcnt = 0;
-	for(n=0;n<dz->linecnt;n++) {
-		if(dz->wordcnt[n] < 2) {
-			sprintf(errstr,"PRoblem getting line times: get_times_and_timediffs()\n");
-			return(PROGRAM_ERROR);
-		}
-		timeloc = total_wordcnt + MIX_TIMEPOS;
-		if(sscanf(dz->wordstor[timeloc],"%lf",&(timestor[n]))!=1) {
-			sprintf(errstr,"Problem reading time: get_times_and_timediffs()\n");
-			return(PROGRAM_ERROR);
-		}
-		total_wordcnt += dz->wordcnt[n];
-	}
-	return(FINISHED);
+    int n, timeloc;
+    int total_wordcnt = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        if(dz->wordcnt[n] < 2) {
+            sprintf(errstr,"PRoblem getting line times: get_times_and_timediffs()\n");
+            return(PROGRAM_ERROR);
+        }
+        timeloc = total_wordcnt + MIX_TIMEPOS;
+        if(sscanf(dz->wordstor[timeloc],"%lf",&(timestor[n]))!=1) {
+            sprintf(errstr,"Problem reading time: get_times_and_timediffs()\n");
+            return(PROGRAM_ERROR);
+        }
+        total_wordcnt += dz->wordcnt[n];
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************** ADJUST_STEREO **************************/
 /************************** ADJUST_STEREO **************************/
 
 
 int adjust_stereo(int lineno,int total_words,int wordcnt,double param,dataptr dz)
 int adjust_stereo(int lineno,int total_words,int wordcnt,double param,dataptr dz)
 {
 {
-	int  exit_status;
-	char *thisword;
-	int  chans;
-	int levelwordno = total_words + MIX_LEVELPOS;
-	int lpanwordno  = total_words + MIX_PANPOS;
-	int rpanwordno  = total_words + MIX_RPANPOS;
-	int chanwordno  = total_words + MIX_CHANPOS;
-	switch(wordcnt) {
-	case(MIX_MINLINE):
-		thisword = dz->wordstor[chanwordno];
-		if(sscanf(thisword,"%d",&chans)!=1) {
-			sprintf(errstr,"Failed to get channel count: adjust_stereo()\n");
-			return(PROGRAM_ERROR);
-		}
-		switch(chans) {
-		case(MONO):				
-			switch(dz->mode) {
-			case(MSW_NARROWED):	return(FINISHED);	/* mono,   unpanned, files can't be narrowed */
-			default:  			return treat_short_mono_line(lineno,levelwordno,param,dz);
-			}					/* mono,   unpanned, wordstor has to be extended to take 1 new vals */
-			break;				/* stereo, unpanned, wordstor has to be extended to take 3 new vals */
-		case(STEREO):			return treat_short_stereo_line(lineno,levelwordno,param,dz);
-		default:
-			sprintf(errstr,"Invalid channel count: adjust_stereo()\n");
-			return(PROGRAM_ERROR);
-		}
-		break; 
-	case(MIX_MAXLINE):
-		if((exit_status = adjust_position(&(dz->wordstor[rpanwordno]),param,dz))<0)
-			return(exit_status);
-		/* fall thro */
-	case(MIX_MIDLINE):
-		return adjust_position(&(dz->wordstor[lpanwordno]),param,dz);
-		break;
-	default:
-		sprintf(errstr,"Impossible wordcnt: adjust_stereo()\n");
-		return(PROGRAM_ERROR);
-	}
-	return(FINISHED);	/* NOTREACHED */
+    int  exit_status;
+    char *thisword;
+    int  chans;
+    int levelwordno = total_words + MIX_LEVELPOS;
+    int lpanwordno  = total_words + MIX_PANPOS;
+    int rpanwordno  = total_words + MIX_RPANPOS;
+    int chanwordno  = total_words + MIX_CHANPOS;
+    switch(wordcnt) {
+    case(MIX_MINLINE):
+        thisword = dz->wordstor[chanwordno];
+        if(sscanf(thisword,"%d",&chans)!=1) {
+            sprintf(errstr,"Failed to get channel count: adjust_stereo()\n");
+            return(PROGRAM_ERROR);
+        }
+        switch(chans) {
+        case(MONO):
+            switch(dz->mode) {
+            case(MSW_NARROWED):     return(FINISHED);       /* mono,   unpanned, files can't be narrowed */
+            default:                        return treat_short_mono_line(lineno,levelwordno,param,dz);
+            }                                       /* mono,   unpanned, wordstor has to be extended to take 1 new vals */
+            break;                          /* stereo, unpanned, wordstor has to be extended to take 3 new vals */
+        case(STEREO):                   return treat_short_stereo_line(lineno,levelwordno,param,dz);
+        default:
+            sprintf(errstr,"Invalid channel count: adjust_stereo()\n");
+            return(PROGRAM_ERROR);
+        }
+        break;
+    case(MIX_MAXLINE):
+        if((exit_status = adjust_position(&(dz->wordstor[rpanwordno]),param,dz))<0)
+            return(exit_status);
+        /* fall thro */
+    case(MIX_MIDLINE):
+        return adjust_position(&(dz->wordstor[lpanwordno]),param,dz);
+        break;
+    default:
+        sprintf(errstr,"Impossible wordcnt: adjust_stereo()\n");
+        return(PROGRAM_ERROR);
+    }
+    return(FINISHED);       /* NOTREACHED */
 }
 }
 
 
 /************************* ADJUST_POSITION ******************************/
 /************************* ADJUST_POSITION ******************************/
 
 
 int adjust_position(char **thisword,double param,dataptr dz)
 int adjust_position(char **thisword,double param,dataptr dz)
 {
 {
-	double position;
-	int    newlen;
-	if(dz->mode==MSW_NARROWED) {
-		if(!strcmp(*thisword,"C"))
-			position = 0.0;
-		else if(!strcmp(*thisword,"L"))
-			position = -1.0;
-		else if(!strcmp(*thisword,"R"))
-			position = 1.0;
-		else if(sscanf(*thisword,"%lf",&position)!=1) {
-			sprintf(errstr,"Failed to get pan value: adjust_position()\n");
-			return(PROGRAM_ERROR);
-		}
-		param *= position;
-	}
-	sprintf(errstr,"%.4lf",param);	
-	newlen = strlen(errstr);
-	if(newlen > (int)strlen(*thisword)) {
-		if((*thisword = 
-		(char *)realloc(*thisword,(newlen+1) * sizeof(char)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-			return(MEMORY_ERROR);
-		}
-	}
-	strcpy(*thisword,errstr);
-	return(FINISHED);
+    double position;
+    int    newlen;
+    if(dz->mode==MSW_NARROWED) {
+        if(!strcmp(*thisword,"C"))
+            position = 0.0;
+        else if(!strcmp(*thisword,"L"))
+            position = -1.0;
+        else if(!strcmp(*thisword,"R"))
+            position = 1.0;
+        else if(sscanf(*thisword,"%lf",&position)!=1) {
+            sprintf(errstr,"Failed to get pan value: adjust_position()\n");
+            return(PROGRAM_ERROR);
+        }
+        param *= position;
+    }
+    sprintf(errstr,"%.4lf",param);
+    newlen = strlen(errstr);
+    if(newlen > (int)strlen(*thisword)) {
+        if((*thisword =
+            (char *)realloc(*thisword,(newlen+1) * sizeof(char)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+            return(MEMORY_ERROR);
+        }
+    }
+    strcpy(*thisword,errstr);
+    return(FINISHED);
 }
 }
 
 
 /************************* TREAT_SHORT_STEREO_LINE ******************************/
 /************************* TREAT_SHORT_STEREO_LINE ******************************/
@@ -287,49 +287,49 @@ int treat_short_stereo_line(int lineno,int wordno,double param,dataptr dz)
 
 
 #define STEREO_EXTRA_WORDS (3)
 #define STEREO_EXTRA_WORDS (3)
 
 
-	int n, m;
-	int  wordlen;
-	if((dz->wordstor = (char **)realloc(dz->wordstor,(dz->all_words + STEREO_EXTRA_WORDS) * sizeof(char *)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to reallocate word store.\n");
-		return(MEMORY_ERROR);
-	}
-	for(n=0,m=dz->all_words;n<STEREO_EXTRA_WORDS;n++,m++)
-		dz->wordstor[m] = NULL;
-	dz->all_words += STEREO_EXTRA_WORDS;
-	for(n=dz->all_words-STEREO_EXTRA_WORDS-1;n>wordno;n--)
-		dz->wordstor[n+STEREO_EXTRA_WORDS] = dz->wordstor[n];
-	dz->wordcnt[lineno] += STEREO_EXTRA_WORDS;		 
-	for(n=wordno+1;n<=wordno+STEREO_EXTRA_WORDS;n++)
-		dz->wordstor[n] = NULL;
-
-	switch(dz->mode) {
-	case(MSW_NARROWED):		sprintf(errstr,"%.4lf",-param);		break;
-	default:				sprintf(errstr,"%.4lf",param);		break;
-	}
-
-	wordlen = strlen(errstr);
-	if((dz->wordstor[wordno+1] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+1+1);
-		return(MEMORY_ERROR);
-	}	
-	strcpy(dz->wordstor[wordno+1],errstr);
-
-	wordlen = strlen(dz->wordstor[wordno]);
-	if((dz->wordstor[wordno+2] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+2+1);
-		return(MEMORY_ERROR);
-	}	
-	strcpy(dz->wordstor[wordno+2],dz->wordstor[wordno]);
-
-	sprintf(errstr,"%.4lf",param);
-	wordlen = strlen(errstr);
-	if((dz->wordstor[wordno+3] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+3+1);
-		return(MEMORY_ERROR);
-	}	
-	strcpy(dz->wordstor[wordno+3],errstr);
-	return(FINISHED);
-}			
+    int n, m;
+    int  wordlen;
+    if((dz->wordstor = (char **)realloc(dz->wordstor,(dz->all_words + STEREO_EXTRA_WORDS) * sizeof(char *)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to reallocate word store.\n");
+        return(MEMORY_ERROR);
+    }
+    for(n=0,m=dz->all_words;n<STEREO_EXTRA_WORDS;n++,m++)
+        dz->wordstor[m] = NULL;
+    dz->all_words += STEREO_EXTRA_WORDS;
+    for(n=dz->all_words-STEREO_EXTRA_WORDS-1;n>wordno;n--)
+        dz->wordstor[n+STEREO_EXTRA_WORDS] = dz->wordstor[n];
+    dz->wordcnt[lineno] += STEREO_EXTRA_WORDS;
+    for(n=wordno+1;n<=wordno+STEREO_EXTRA_WORDS;n++)
+        dz->wordstor[n] = NULL;
+
+    switch(dz->mode) {
+    case(MSW_NARROWED):             sprintf(errstr,"%.4lf",-param);         break;
+    default:                                sprintf(errstr,"%.4lf",param);          break;
+    }
+
+    wordlen = strlen(errstr);
+    if((dz->wordstor[wordno+1] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+1+1);
+        return(MEMORY_ERROR);
+    }
+    strcpy(dz->wordstor[wordno+1],errstr);
+
+    wordlen = strlen(dz->wordstor[wordno]);
+    if((dz->wordstor[wordno+2] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+2+1);
+        return(MEMORY_ERROR);
+    }
+    strcpy(dz->wordstor[wordno+2],dz->wordstor[wordno]);
+
+    sprintf(errstr,"%.4lf",param);
+    wordlen = strlen(errstr);
+    if((dz->wordstor[wordno+3] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to allocate wordstore %d\n",wordno+3+1);
+        return(MEMORY_ERROR);
+    }
+    strcpy(dz->wordstor[wordno+3],errstr);
+    return(FINISHED);
+}
 
 
 /************************* TREAT_SHORT_MONO_LINE ******************************/
 /************************* TREAT_SHORT_MONO_LINE ******************************/
 
 
@@ -337,53 +337,53 @@ int treat_short_mono_line(int lineno,int wordno,double param,dataptr dz)
 {
 {
 
 
 #define MONO_EXTRA_WORDS (1)
 #define MONO_EXTRA_WORDS (1)
-	int n, m;
-	int  wordlen;
-	if((dz->wordstor = (char **)realloc(dz->wordstor,(dz->all_words + MONO_EXTRA_WORDS) * sizeof(char *)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for word stores.\n");
-		return(MEMORY_ERROR);
-	}
-	for(n=0,m=dz->all_words;n<MONO_EXTRA_WORDS;n++,m++)
-		dz->wordstor[m] = NULL;
-	dz->all_words += MONO_EXTRA_WORDS;
-	for(n=dz->all_words-MONO_EXTRA_WORDS-1;n>wordno;n--)
-		dz->wordstor[n+MONO_EXTRA_WORDS] = dz->wordstor[n];
-	dz->wordcnt[lineno] += MONO_EXTRA_WORDS;		 
-	dz->wordstor[wordno+1] = NULL;
-
-	sprintf(errstr,"%.4lf",param);
-	wordlen = strlen(errstr);
-	if((dz->wordstor[wordno+1] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for word store %d\n",wordno+1+1);
-		return(MEMORY_ERROR);
-	}	
-	strcpy(dz->wordstor[wordno+1],errstr);
-	return(FINISHED);
-}			
+    int n, m;
+    int  wordlen;
+    if((dz->wordstor = (char **)realloc(dz->wordstor,(dz->all_words + MONO_EXTRA_WORDS) * sizeof(char *)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for word stores.\n");
+        return(MEMORY_ERROR);
+    }
+    for(n=0,m=dz->all_words;n<MONO_EXTRA_WORDS;n++,m++)
+        dz->wordstor[m] = NULL;
+    dz->all_words += MONO_EXTRA_WORDS;
+    for(n=dz->all_words-MONO_EXTRA_WORDS-1;n>wordno;n--)
+        dz->wordstor[n+MONO_EXTRA_WORDS] = dz->wordstor[n];
+    dz->wordcnt[lineno] += MONO_EXTRA_WORDS;
+    dz->wordstor[wordno+1] = NULL;
+
+    sprintf(errstr,"%.4lf",param);
+    wordlen = strlen(errstr);
+    if((dz->wordstor[wordno+1] = (char *)malloc((wordlen+1) * sizeof(char)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for word store %d\n",wordno+1+1);
+        return(MEMORY_ERROR);
+    }
+    strcpy(dz->wordstor[wordno+1],errstr);
+    return(FINISHED);
+}
 
 
 /************************* INVESTIGATE_TIMINGS ******************************/
 /************************* INVESTIGATE_TIMINGS ******************************/
 
 
 int investigate_timings(double *duration,double *min_time,dataptr dz)
 int investigate_timings(double *duration,double *min_time,dataptr dz)
 {
 {
-	int exit_status;
-	int   n;
-	double *timestor;
-	double max_time;
-	if((dz->parray[MSW_TIMESTOR] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for times store.\n");
-		return(MEMORY_ERROR);
-	}
-	timestor = dz->parray[MSW_TIMESTOR];
-	if((exit_status = get_times(timestor,dz))<0)
-		return(exit_status);
-	max_time  = timestor[dz->iparam[MSH_STARTLINE]];
-	*min_time = timestor[dz->iparam[MSH_STARTLINE]];
-	for(n=dz->iparam[MSH_STARTLINE]+1;n<dz->iparam[MSH_ENDLINE];n++) {
-		max_time  = max(timestor[n],max_time);
-		*min_time = min(timestor[n],*min_time);
-	}
-	*duration = max_time - *min_time;
-	return(FINISHED);
+    int exit_status;
+    int   n;
+    double *timestor;
+    double max_time;
+    if((dz->parray[MSW_TIMESTOR] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for times store.\n");
+        return(MEMORY_ERROR);
+    }
+    timestor = dz->parray[MSW_TIMESTOR];
+    if((exit_status = get_times(timestor,dz))<0)
+        return(exit_status);
+    max_time  = timestor[dz->iparam[MSH_STARTLINE]];
+    *min_time = timestor[dz->iparam[MSH_STARTLINE]];
+    for(n=dz->iparam[MSH_STARTLINE]+1;n<dz->iparam[MSH_ENDLINE];n++) {
+        max_time  = max(timestor[n],max_time);
+        *min_time = min(timestor[n],*min_time);
+    }
+    *duration = max_time - *min_time;
+    return(FINISHED);
 }
 }
 
 
 //TW UPDATE: NEW FUNCTION
 //TW UPDATE: NEW FUNCTION
@@ -391,109 +391,108 @@ int investigate_timings(double *duration,double *min_time,dataptr dz)
 
 
 int panmix(dataptr dz)
 int panmix(dataptr dz)
 {
 {
-	int newlen, exit_status;
-	int baspos = 0, basposnext = 0, n, linelen;		   /*RWD Nov 2003 added init for basposnext */
-	int levelwordno, lpanwordno, rpanwordno, chanwordno;
-	double time, level;
-	char temp[200];
-	int *maxwordsize;
-	for(n=0;n<dz->linecnt;n++) {
-		basposnext += dz->wordcnt[n];
-		levelwordno = baspos + MIX_LEVELPOS;
-		lpanwordno  = baspos + MIX_PANPOS;
-		rpanwordno  = baspos + MIX_RPANPOS;
-		chanwordno  = baspos + MIX_CHANPOS;
-		time = atof(dz->wordstor[baspos + 1]);
-		if(dz->brksize[PAN_PAN]) {
-			if((exit_status = read_value_from_brktable(time,PAN_PAN,dz))<0)
-				return(exit_status);
-		}
-		linelen = basposnext - baspos;
-		switch(linelen) {
-		case(MIX_MINLINE):				/* STEREO CASE : SHORT LINE */
-			level = atof(dz->wordstor[levelwordno]);
-			level /= 2.0;
-			sprintf(errstr,"%.4lf",level);
-			strcat(errstr," ");
-			sprintf(temp,"%.4lf",dz->param[PAN_PAN]);	
-			strcat(temp," ");
-			strcat(errstr,temp);
-			strcpy(temp,errstr);
-			strcat(errstr,temp);
-			newlen = strlen(errstr);
-			if(newlen > (int)strlen(dz->wordstor[levelwordno])) {
-				if((dz->wordstor[levelwordno] = 
-				(char *)realloc(dz->wordstor[levelwordno],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			strcpy(dz->wordstor[levelwordno],errstr);
-			break;
-		case(MIX_MAXLINE):				/* STEREO CASE : LONG LINE */
-			level = atof(dz->wordstor[levelwordno]);
-			level += atof(dz->wordstor[levelwordno+2]);
-			level /= 4.0;				/* Average level: = (level_left + level-right) / 2.0 */
-										/* This average level from BOTH channels is to be put at SAME position */
-										/* Therefore, divide by two again */
-			sprintf(errstr,"%.4lf",level);
-			newlen = strlen(errstr);
-
-			if(newlen > (int)strlen(dz->wordstor[levelwordno])) {
-				if((dz->wordstor[levelwordno] = 
-				(char *)realloc(dz->wordstor[levelwordno],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			if(newlen > (int)strlen(dz->wordstor[levelwordno+2])) {
-				if((dz->wordstor[levelwordno+2] = 
-				(char *)realloc(dz->wordstor[levelwordno+2],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			strcpy(dz->wordstor[levelwordno],errstr);
-			strcpy(dz->wordstor[levelwordno+2],errstr);
-
-			sprintf(errstr,"%.4lf",dz->param[PAN_PAN]);	
-			if(newlen > (int)strlen(dz->wordstor[lpanwordno])) {
-				if((dz->wordstor[lpanwordno] = 
-				(char *)realloc(dz->wordstor[lpanwordno],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			if(newlen > (int)strlen(dz->wordstor[rpanwordno])) {
-				if((dz->wordstor[rpanwordno] = 
-				(char *)realloc(dz->wordstor[rpanwordno],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			strcpy(dz->wordstor[lpanwordno],errstr);
-			strcpy(dz->wordstor[rpanwordno],errstr);
-			break;
-		case(MIX_MIDLINE):				/* MONO CASE */
-			sprintf(errstr,"%.4lf",dz->param[PAN_PAN]);	
-			newlen = strlen(errstr);
-			if(newlen > (int)strlen(dz->wordstor[lpanwordno])) {
-				if((dz->wordstor[lpanwordno] = 
-				(char *)realloc(dz->wordstor[lpanwordno],(newlen+1) * sizeof(char)))==NULL) {
-					sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
-					return(MEMORY_ERROR);
-				}
-			}
-			strcpy(dz->wordstor[lpanwordno],errstr);
-			break;
-		}
-		baspos = basposnext;
-	}
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
-		return(exit_status);
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
-		return(exit_status);
-	free(maxwordsize);
-	return(FINISHED);
+    int newlen, exit_status;
+    int baspos = 0, basposnext = 0, n, linelen;                /*RWD Nov 2003 added init for basposnext */
+    int levelwordno, lpanwordno, rpanwordno;
+    double time, level;
+    char temp[200];
+    int *maxwordsize;
+    for(n=0;n<dz->linecnt;n++) {
+        basposnext += dz->wordcnt[n];
+        levelwordno = baspos + MIX_LEVELPOS;
+        lpanwordno  = baspos + MIX_PANPOS;
+        rpanwordno  = baspos + MIX_RPANPOS;
+        //chanwordno  = baspos + MIX_CHANPOS;
+        time = atof(dz->wordstor[baspos + 1]);
+        if(dz->brksize[PAN_PAN]) {
+            if((exit_status = read_value_from_brktable(time,PAN_PAN,dz))<0)
+                return(exit_status);
+        }
+        linelen = basposnext - baspos;
+        switch(linelen) {
+        case(MIX_MINLINE):                              /* STEREO CASE : SHORT LINE */
+            level = atof(dz->wordstor[levelwordno]);
+            level /= 2.0;
+            sprintf(errstr,"%.4lf",level);
+            strcat(errstr," ");
+            sprintf(temp,"%.4lf",dz->param[PAN_PAN]);
+            strcat(temp," ");
+            strcat(errstr,temp);
+            strcpy(temp,errstr);
+            strcat(errstr,temp);
+            newlen = strlen(errstr);
+            if(newlen > (int)strlen(dz->wordstor[levelwordno])) {
+                if((dz->wordstor[levelwordno] =
+                    (char *)realloc(dz->wordstor[levelwordno],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            strcpy(dz->wordstor[levelwordno],errstr);
+            break;
+        case(MIX_MAXLINE):                              /* STEREO CASE : LONG LINE */
+            level = atof(dz->wordstor[levelwordno]);
+            level += atof(dz->wordstor[levelwordno+2]);
+            level /= 4.0;                           /* Average level: = (level_left + level-right) / 2.0 */
+            /* This average level from BOTH channels is to be put at SAME position */
+            /* Therefore, divide by two again */
+            sprintf(errstr,"%.4lf",level);
+            newlen = strlen(errstr);
+
+            if(newlen > (int)strlen(dz->wordstor[levelwordno])) {
+                if((dz->wordstor[levelwordno] =
+                    (char *)realloc(dz->wordstor[levelwordno],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            if(newlen > (int)strlen(dz->wordstor[levelwordno+2])) {
+                if((dz->wordstor[levelwordno+2] =
+                    (char *)realloc(dz->wordstor[levelwordno+2],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            strcpy(dz->wordstor[levelwordno],errstr);
+            strcpy(dz->wordstor[levelwordno+2],errstr);
+
+            sprintf(errstr,"%.4lf",dz->param[PAN_PAN]);
+            if(newlen > (int)strlen(dz->wordstor[lpanwordno])) {
+                if((dz->wordstor[lpanwordno] =
+                    (char *)realloc(dz->wordstor[lpanwordno],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            if(newlen > (int)strlen(dz->wordstor[rpanwordno])) {
+                if((dz->wordstor[rpanwordno] =
+                    (char *)realloc(dz->wordstor[rpanwordno],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            strcpy(dz->wordstor[lpanwordno],errstr);
+            strcpy(dz->wordstor[rpanwordno],errstr);
+            break;
+        case(MIX_MIDLINE):                              /* MONO CASE */
+            sprintf(errstr,"%.4lf",dz->param[PAN_PAN]);
+            newlen = strlen(errstr);
+            if(newlen > (int)strlen(dz->wordstor[lpanwordno])) {
+                if((dz->wordstor[lpanwordno] =
+                    (char *)realloc(dz->wordstor[lpanwordno],(newlen+1) * sizeof(char)))==NULL) {
+                    sprintf(errstr,"INSUFFICIENT MEMORY to reallocate thisword store.\n");
+                    return(MEMORY_ERROR);
+                }
+            }
+            strcpy(dz->wordstor[lpanwordno],errstr);
+            break;
+        }
+        baspos = basposnext;
+    }
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
+        return(exit_status);
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
+        return(exit_status);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
-

File diff suppressed because it is too large
+ 999 - 999
dev/submix/mixshuf1.c


+ 290 - 290
dev/submix/mixshuf2.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -52,334 +52,334 @@ static int  output_mixfile_line(char **wordstor,int total_words,int wordcnt,int
 
 
 int do_time_and_name_copy(dataptr dz)
 int do_time_and_name_copy(dataptr dz)
 {
 {
-	int  exit_status;
-	int  extra_words = 0;
-	int  *maxwordsize;
-	int total_words = 0, new_words = 0, words_above = 0, moveindex;
-	int new_total_words, oldwordpos, orig_oldwordpos, newwordpos;
-	int  n, lineno, wordno, newlines, lines_above, oldlinecnt;
-
-	if(dz->mode==MSH_DUPL_AND_RENAME) {	   /* space for the new sndfilename must bhave been allocated */
-		if(dz->extra_word<0) {
-			sprintf(errstr,"extra_word not accounted for: do_time_and_name_copy()\n");
-			return(PROGRAM_ERROR);
-		}
-		extra_words = 1;
-	}
-
-	newlines    = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
-	lines_above = dz->linecnt - dz->iparam[MSH_ENDLINE];
-
-	for(n=0;n<dz->linecnt;n++)
-		total_words += dz->wordcnt[n];
-
-	for(n=dz->iparam[MSH_ENDLINE];n<dz->linecnt;n++)
-		words_above += dz->wordcnt[n];
-
-	for(n=dz->iparam[MSH_STARTLINE];n<dz->iparam[MSH_ENDLINE];n++)
-		new_words += dz->wordcnt[n];
-
-	new_total_words = total_words + new_words;
-
-	if((dz->wordstor = (char **)realloc(dz->wordstor,(new_total_words+extra_words) * sizeof(char *)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for word store.\n");
-		return(MEMORY_ERROR);								/* alloc space for all new words */
-	}
-	for(n=total_words+extra_words; n < new_total_words+extra_words;n++)
-		dz->wordstor[n] = NULL;
-
-	oldlinecnt = dz->linecnt;
-	dz->linecnt += newlines;
-
-	if((dz->wordcnt = (int *)realloc(dz->wordcnt,dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY for word count store.\n");
-		return(MEMORY_ERROR);								/* alloc space for all new line wordcnts */
-	}
-	for(n=oldlinecnt; n < dz->linecnt;n++)
-		dz->wordcnt[n] = 0;
-
-	dz->all_words  += new_words;							/* update total wordcnt: good housekeeping */
-			
-	oldwordpos      = total_words + extra_words     - 1;
-	newwordpos      = new_total_words + extra_words - 1;
-												/* 'MOVE' WORDS BEYOND THE ACTED-ON LINES + ANY EXTRA_WORD */
-	for(n=0;n<(words_above+extra_words);n++) {	
-		dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
-		newwordpos--;
-		oldwordpos--;
-		if(oldwordpos<0) {
-			sprintf(errstr,"Accounting problem 0: do_time_and_name_copy()\n");
-			return(PROGRAM_ERROR);
-		}
-	}
-	for(n=oldlinecnt;n<dz->linecnt;n++)			/* Put correct wordcnt in place for these moved lines */
-		dz->wordcnt[n] = dz->wordcnt[n - newlines];
- 
- 	if(dz->mode==MSH_DUPL_AND_RENAME)  			/* adjust address where new sndfilename is now found */
-		dz->extra_word += new_words;
-
-	oldwordpos = 0;								/* GO TO THE END OF THE WORDS TO DUPLICATE */
-	for(lineno=0;lineno<dz->iparam[MSH_ENDLINE];lineno++)
-		oldwordpos += dz->wordcnt[lineno];
-	oldwordpos--;
-	newwordpos = oldwordpos + new_words; 		/* MOVING BACKWARDS, DUPLICATE THE ACTED-ON LINES */
-
-	for(lineno = dz->iparam[MSH_ENDLINE]-1,moveindex = newlines;lineno>=dz->iparam[MSH_STARTLINE];lineno--,moveindex--) {
-
-		orig_oldwordpos = oldwordpos;			/* CREATE WORDS IN A DUPLICATE LINE */
-		for(wordno=dz->wordcnt[lineno]-1;wordno>=0;wordno--) {		
-												/* CHECKING THE CHANNEL If process DEMANDS IT */
-  			if(wordno==MIX_CHANPOS && dz->mode==MSH_DUPL_AND_RENAME && dz->vflag[MSH_NOCHECK]==FALSE) {
-				if((exit_status = check_chans(lineno,oldwordpos,dz))<0)
-					return(exit_status);
-			}									/* SUBSTITUTING NEW NAME: IF process DEMANDS IT */
-  			if(wordno==MIX_NAMEPOS && dz->mode==MSH_DUPL_AND_RENAME)
-				dz->wordstor[newwordpos] = dz->wordstor[dz->extra_word];
-			else
-				dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
-			oldwordpos--;
-			newwordpos--;
-			if(lineno > 0 && wordno > 0) {
-				if(oldwordpos<0) {
-					sprintf(errstr,"Accounting problem 1: do_time_and_name_copy()\n");
-					return(PROGRAM_ERROR);
-				}
-			}
-		}
-		dz->wordcnt[lineno+moveindex] = dz->wordcnt[lineno];
-
-		oldwordpos = orig_oldwordpos;			/* THEN ALSO MOVE WORDS OF ORIGINAL LINE */
-		if(newwordpos < oldwordpos) {
-			sprintf(errstr,"Accounting problem 2: do_time_and_name_copy()\n");
-			return(PROGRAM_ERROR);
-		}
-		for(wordno=dz->wordcnt[lineno]-1;wordno>=0;wordno--) {
-			dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
-			oldwordpos--;
-			newwordpos--;
-		}
-		if(moveindex-1 < 0) {
-			sprintf(errstr,"Accounting problem 2a: do_time_and_name_copy()\n");
-			return(PROGRAM_ERROR);
-		}
-		dz->wordcnt[lineno+moveindex-1] = dz->wordcnt[lineno];
-	}
-											
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
-		return(exit_status);
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
-		return(exit_status);
-	free(maxwordsize);
-	return(FINISHED);
+    int  exit_status;
+    int  extra_words = 0;
+    int  *maxwordsize;
+    int total_words = 0, new_words = 0, words_above = 0, moveindex;
+    int new_total_words, oldwordpos, orig_oldwordpos, newwordpos;
+    int  n, lineno, wordno, newlines, oldlinecnt;
+
+    if(dz->mode==MSH_DUPL_AND_RENAME) {        /* space for the new sndfilename must bhave been allocated */
+        if(dz->extra_word<0) {
+            sprintf(errstr,"extra_word not accounted for: do_time_and_name_copy()\n");
+            return(PROGRAM_ERROR);
+        }
+        extra_words = 1;
+    }
+
+    newlines    = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
+    //lines_above = dz->linecnt - dz->iparam[MSH_ENDLINE];
+
+    for(n=0;n<dz->linecnt;n++)
+        total_words += dz->wordcnt[n];
+
+    for(n=dz->iparam[MSH_ENDLINE];n<dz->linecnt;n++)
+        words_above += dz->wordcnt[n];
+
+    for(n=dz->iparam[MSH_STARTLINE];n<dz->iparam[MSH_ENDLINE];n++)
+        new_words += dz->wordcnt[n];
+
+    new_total_words = total_words + new_words;
+
+    if((dz->wordstor = (char **)realloc(dz->wordstor,(new_total_words+extra_words) * sizeof(char *)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for word store.\n");
+        return(MEMORY_ERROR);                                                           /* alloc space for all new words */
+    }
+    for(n=total_words+extra_words; n < new_total_words+extra_words;n++)
+        dz->wordstor[n] = NULL;
+
+    oldlinecnt = dz->linecnt;
+    dz->linecnt += newlines;
+
+    if((dz->wordcnt = (int *)realloc(dz->wordcnt,dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY for word count store.\n");
+        return(MEMORY_ERROR);                                                           /* alloc space for all new line wordcnts */
+    }
+    for(n=oldlinecnt; n < dz->linecnt;n++)
+        dz->wordcnt[n] = 0;
+
+    dz->all_words  += new_words;                                                    /* update total wordcnt: good housekeeping */
+
+    oldwordpos      = total_words + extra_words     - 1;
+    newwordpos      = new_total_words + extra_words - 1;
+    /* 'MOVE' WORDS BEYOND THE ACTED-ON LINES + ANY EXTRA_WORD */
+    for(n=0;n<(words_above+extra_words);n++) {
+        dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
+        newwordpos--;
+        oldwordpos--;
+        if(oldwordpos<0) {
+            sprintf(errstr,"Accounting problem 0: do_time_and_name_copy()\n");
+            return(PROGRAM_ERROR);
+        }
+    }
+    for(n=oldlinecnt;n<dz->linecnt;n++)                     /* Put correct wordcnt in place for these moved lines */
+        dz->wordcnt[n] = dz->wordcnt[n - newlines];
+
+    if(dz->mode==MSH_DUPL_AND_RENAME)                       /* adjust address where new sndfilename is now found */
+        dz->extra_word += new_words;
+
+    oldwordpos = 0;                                                         /* GO TO THE END OF THE WORDS TO DUPLICATE */
+    for(lineno=0;lineno<dz->iparam[MSH_ENDLINE];lineno++)
+        oldwordpos += dz->wordcnt[lineno];
+    oldwordpos--;
+    newwordpos = oldwordpos + new_words;            /* MOVING BACKWARDS, DUPLICATE THE ACTED-ON LINES */
+
+    for(lineno = dz->iparam[MSH_ENDLINE]-1,moveindex = newlines;lineno>=dz->iparam[MSH_STARTLINE];lineno--,moveindex--) {
+
+        orig_oldwordpos = oldwordpos;                   /* CREATE WORDS IN A DUPLICATE LINE */
+        for(wordno=dz->wordcnt[lineno]-1;wordno>=0;wordno--) {
+            /* CHECKING THE CHANNEL If process DEMANDS IT */
+            if(wordno==MIX_CHANPOS && dz->mode==MSH_DUPL_AND_RENAME && dz->vflag[MSH_NOCHECK]==FALSE) {
+                if((exit_status = check_chans(lineno,oldwordpos,dz))<0)
+                    return(exit_status);
+            }                                                                       /* SUBSTITUTING NEW NAME: IF process DEMANDS IT */
+            if(wordno==MIX_NAMEPOS && dz->mode==MSH_DUPL_AND_RENAME)
+                dz->wordstor[newwordpos] = dz->wordstor[dz->extra_word];
+            else
+                dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
+            oldwordpos--;
+            newwordpos--;
+            if(lineno > 0 && wordno > 0) {
+                if(oldwordpos<0) {
+                    sprintf(errstr,"Accounting problem 1: do_time_and_name_copy()\n");
+                    return(PROGRAM_ERROR);
+                }
+            }
+        }
+        dz->wordcnt[lineno+moveindex] = dz->wordcnt[lineno];
+
+        oldwordpos = orig_oldwordpos;                   /* THEN ALSO MOVE WORDS OF ORIGINAL LINE */
+        if(newwordpos < oldwordpos) {
+            sprintf(errstr,"Accounting problem 2: do_time_and_name_copy()\n");
+            return(PROGRAM_ERROR);
+        }
+        for(wordno=dz->wordcnt[lineno]-1;wordno>=0;wordno--) {
+            dz->wordstor[newwordpos] = dz->wordstor[oldwordpos];
+            oldwordpos--;
+            newwordpos--;
+        }
+        if(moveindex-1 < 0) {
+            sprintf(errstr,"Accounting problem 2a: do_time_and_name_copy()\n");
+            return(PROGRAM_ERROR);
+        }
+        dz->wordcnt[lineno+moveindex-1] = dz->wordcnt[lineno];
+    }
+
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
+        return(exit_status);
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
+        return(exit_status);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /************************* OUTPUT_MIXFILE_LINES ******************************/
 /************************* OUTPUT_MIXFILE_LINES ******************************/
 
 
 int output_mixfile_lines(int *maxwordsize,dataptr dz)
 int output_mixfile_lines(int *maxwordsize,dataptr dz)
 {
 {
-	int exit_status;
-	int n;
-	int total_words = 0;
-	for(n=0;n<dz->linecnt;n++) {						
-		if((exit_status = output_mixfile_line(dz->wordstor,total_words,dz->wordcnt[n],maxwordsize,dz))<0)
-			return(exit_status);
-		total_words += dz->wordcnt[n];
-	}
-	return(FINISHED);
+    int exit_status;
+    int n;
+    int total_words = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        if((exit_status = output_mixfile_line(dz->wordstor,total_words,dz->wordcnt[n],maxwordsize,dz))<0)
+            return(exit_status);
+        total_words += dz->wordcnt[n];
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************* CHECK_CHANS ******************************/
 /************************* CHECK_CHANS ******************************/
 
 
 int check_chans(int lineno,int oldwordpos,dataptr dz)
 int check_chans(int lineno,int oldwordpos,dataptr dz)
 {
 {
-	int chans;
-	if(sscanf(dz->wordstor[oldwordpos],"%d",&chans)!=1) {
-		sprintf(errstr,"Failed to read channel value:line %d: check_chans()\n",lineno+1);
-		return(PROGRAM_ERROR);
-	}
-	if(chans!=dz->otherfile->channels) {
-		sprintf(errstr,"New named file has incompatible channel cnt: line %d: check_chans()\n",lineno+1);
-		return(DATA_ERROR);
-	}
-	return(FINISHED);
+    int chans;
+    if(sscanf(dz->wordstor[oldwordpos],"%d",&chans)!=1) {
+        sprintf(errstr,"Failed to read channel value:line %d: check_chans()\n",lineno+1);
+        return(PROGRAM_ERROR);
+    }
+    if(chans!=dz->otherfile->channels) {
+        sprintf(errstr,"New named file has incompatible channel cnt: line %d: check_chans()\n",lineno+1);
+        return(DATA_ERROR);
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************* DO_NAME_REVERSE ******************************/
 /************************* DO_NAME_REVERSE ******************************/
 
 
 int do_name_reverse(dataptr dz)
 int do_name_reverse(dataptr dz)
 {
 {
-	int exit_status;
-	int  *maxwordsize;
-	int *name_index;
-	int half_linecnt;
-	char *temp;
-	int lineno, newlineno, total_words = 0;
-
-	if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"do_name_reverse()\n");
-		return(PROGRAM_ERROR);
-	}
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
-		free(name_index);
-		return(exit_status);
-	}
-	for(lineno=0;lineno<dz->linecnt;lineno++) {
-		name_index[lineno] = total_words;
-		total_words += dz->wordcnt[lineno];
-	}
-
-	half_linecnt  = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
-	half_linecnt  = half_linecnt/2; /* TRUNCATE */
-	half_linecnt += dz->iparam[MSH_STARTLINE];
-
-	for(lineno=dz->iparam[MSH_STARTLINE],newlineno=dz->iparam[MSH_ENDLINE]-1;lineno < half_linecnt;lineno++,newlineno--) {
-		temp            					= dz->wordstor[name_index[lineno]];
-		dz->wordstor[name_index[lineno]] 	= dz->wordstor[name_index[newlineno]];
-		dz->wordstor[name_index[newlineno]] = temp;
-	}		
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
-		free(maxwordsize);
-		free(name_index);
-		return(exit_status);
-	}
-	free(maxwordsize);
-	free(name_index);
-	return(FINISHED);
+    int exit_status;
+    int  *maxwordsize;
+    int *name_index;
+    int half_linecnt;
+    char *temp;
+    int lineno, newlineno, total_words = 0;
+
+    if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"do_name_reverse()\n");
+        return(PROGRAM_ERROR);
+    }
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
+        free(name_index);
+        return(exit_status);
+    }
+    for(lineno=0;lineno<dz->linecnt;lineno++) {
+        name_index[lineno] = total_words;
+        total_words += dz->wordcnt[lineno];
+    }
+
+    half_linecnt  = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
+    half_linecnt  = half_linecnt/2; /* TRUNCATE */
+    half_linecnt += dz->iparam[MSH_STARTLINE];
+
+    for(lineno=dz->iparam[MSH_STARTLINE],newlineno=dz->iparam[MSH_ENDLINE]-1;lineno < half_linecnt;lineno++,newlineno--) {
+        temp                                                    = dz->wordstor[name_index[lineno]];
+        dz->wordstor[name_index[lineno]]        = dz->wordstor[name_index[newlineno]];
+        dz->wordstor[name_index[newlineno]] = temp;
+    }
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
+        free(maxwordsize);
+        free(name_index);
+        return(exit_status);
+    }
+    free(maxwordsize);
+    free(name_index);
+    return(FINISHED);
 }
 }
 
 
 /************************* DO_NAME_FREEZE ******************************/
 /************************* DO_NAME_FREEZE ******************************/
 
 
 int do_name_freeze(dataptr dz)
 int do_name_freeze(dataptr dz)
 {
 {
-	int exit_status;
-	int  *maxwordsize;
-	int *name_index;
-	int lineno, total_words = 0;
-
-	if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"do_name_reverse()\n");
-		return(PROGRAM_ERROR);
-	}
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
-		free(name_index);
-		return(exit_status);
-	}	
-	for(lineno=0;lineno<dz->linecnt;lineno++) {
-		name_index[lineno] = total_words;
-		total_words += dz->wordcnt[lineno];
-	}
-
-	for(lineno=dz->iparam[MSH_STARTLINE];lineno < dz->iparam[MSH_ENDLINE];lineno++)
-		dz->wordstor[name_index[lineno]] = dz->wordstor[name_index[dz->iparam[MSH_STARTLINE]]];
-
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
-		free(name_index);
-		free(maxwordsize);
-		return(exit_status);
-	}
-	free(name_index);
-	free(maxwordsize);
-	return(FINISHED);
+    int exit_status;
+    int  *maxwordsize;
+    int *name_index;
+    int lineno, total_words = 0;
+
+    if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"do_name_reverse()\n");
+        return(PROGRAM_ERROR);
+    }
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
+        free(name_index);
+        return(exit_status);
+    }
+    for(lineno=0;lineno<dz->linecnt;lineno++) {
+        name_index[lineno] = total_words;
+        total_words += dz->wordcnt[lineno];
+    }
+
+    for(lineno=dz->iparam[MSH_STARTLINE];lineno < dz->iparam[MSH_ENDLINE];lineno++)
+        dz->wordstor[name_index[lineno]] = dz->wordstor[name_index[dz->iparam[MSH_STARTLINE]]];
+
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
+        free(name_index);
+        free(maxwordsize);
+        return(exit_status);
+    }
+    free(name_index);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /************************** RANDOMISE_NAMES **************************/
 /************************** RANDOMISE_NAMES **************************/
 
 
 int randomise_names(dataptr dz)
 int randomise_names(dataptr dz)
 {
 {
-	int  exit_status;
-	int  *maxwordsize;
-	int *name_index;
-	int lineno, total_words = 0;
-	int n, m, t; 
-	int permlen = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
-	char **permm;
-
-	if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"randomise_names(): 1\n");
-		return(PROGRAM_ERROR);
-	}
-	if((permm = (char **)malloc(permlen * sizeof(char *)))==NULL) {
-		free(name_index);
-		sprintf(errstr,"randomise_names(): 2\n");
-		return(PROGRAM_ERROR);
-	}
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
-		free(name_index);
-		free(permm);
-		return(exit_status);
-	}	
-	for(lineno=0;lineno<dz->linecnt;lineno++) {
-		name_index[lineno] = total_words;
-		total_words += dz->wordcnt[lineno];
-	}
-	for(n=0;n<permlen;n++) {
-		t = (int)(drand48() * (double)(n+1));
-		if(t==n)
-			prefix_word(permm,permlen,name_index,n+dz->iparam[MSH_STARTLINE],dz);
-		else
-			insert_word(permm,permlen,name_index,n+dz->iparam[MSH_STARTLINE],t,dz);
-	}
-	for(n=0,m=dz->iparam[MSH_STARTLINE];n<permlen;n++,m++)
-		dz->wordstor[name_index[m]] = permm[n];
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
-		free(name_index);
-		free(permm);
-		free(maxwordsize);
-		return(exit_status);
-	}
-	free(name_index);
-	free(permm);
-	free(maxwordsize);
-	return(FINISHED);
+    int  exit_status;
+    int  *maxwordsize;
+    int *name_index;
+    int lineno, total_words = 0;
+    int n, m, t;
+    int permlen = dz->iparam[MSH_ENDLINE] - dz->iparam[MSH_STARTLINE];
+    char **permm;
+
+    if((name_index = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"randomise_names(): 1\n");
+        return(PROGRAM_ERROR);
+    }
+    if((permm = (char **)malloc(permlen * sizeof(char *)))==NULL) {
+        free(name_index);
+        sprintf(errstr,"randomise_names(): 2\n");
+        return(PROGRAM_ERROR);
+    }
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0) {
+        free(name_index);
+        free(permm);
+        return(exit_status);
+    }
+    for(lineno=0;lineno<dz->linecnt;lineno++) {
+        name_index[lineno] = total_words;
+        total_words += dz->wordcnt[lineno];
+    }
+    for(n=0;n<permlen;n++) {
+        t = (int)(drand48() * (double)(n+1));
+        if(t==n)
+            prefix_word(permm,permlen,name_index,n+dz->iparam[MSH_STARTLINE],dz);
+        else
+            insert_word(permm,permlen,name_index,n+dz->iparam[MSH_STARTLINE],t,dz);
+    }
+    for(n=0,m=dz->iparam[MSH_STARTLINE];n<permlen;n++,m++)
+        dz->wordstor[name_index[m]] = permm[n];
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0) {
+        free(name_index);
+        free(permm);
+        free(maxwordsize);
+        return(exit_status);
+    }
+    free(name_index);
+    free(permm);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /****************************** INSERT_WORD ****************************/
 /****************************** INSERT_WORD ****************************/
 
 
 void insert_word(char **permm,int permlen,int *name_index,int m,int t,dataptr dz)
 void insert_word(char **permm,int permlen,int *name_index,int m,int t,dataptr dz)
-{   
-	shuflup_words(permm,permlen,t+1);
-	permm[t+1] = dz->wordstor[name_index[m]];
+{
+    shuflup_words(permm,permlen,t+1);
+    permm[t+1] = dz->wordstor[name_index[m]];
 }
 }
 
 
 /****************************** PREFIX_WORD ****************************/
 /****************************** PREFIX_WORD ****************************/
 
 
 void prefix_word(char **permm,int permlen,int *name_index,int m,dataptr dz)
 void prefix_word(char **permm,int permlen,int *name_index,int m,dataptr dz)
 {
 {
-	shuflup_words(permm,permlen,0);
-	permm[0] = dz->wordstor[name_index[m]];
+    shuflup_words(permm,permlen,0);
+    permm[0] = dz->wordstor[name_index[m]];
 }
 }
 
 
 /****************************** SHUFLUP_WORDS ****************************/
 /****************************** SHUFLUP_WORDS ****************************/
 
 
 void shuflup_words(char **permm,int permlen,int k)
 void shuflup_words(char **permm,int permlen,int k)
 {
 {
-	int n;
-	char **i;
-	int z = permlen - 1;
-	i = &(permm[z]);
-	for(n = z; n > k; n--) {
-		*i = *(i-1);
-		i--;
-	}
+    int n;
+    char **i;
+    int z = permlen - 1;
+    i = &(permm[z]);
+    for(n = z; n > k; n--) {
+        *i = *(i-1);
+        i--;
+    }
 }
 }
 
 
 /************************** OUTPUT_MIXFILE_LINE ***************************/
 /************************** OUTPUT_MIXFILE_LINE ***************************/
 
 
 int output_mixfile_line(char **wordstor,int total_words,int wordcnt,int *maxwordsize,dataptr dz)
 int output_mixfile_line(char **wordstor,int total_words,int wordcnt,int *maxwordsize,dataptr dz)
 {
 {
-	int n, m, spacecnt;
-	int wordno;
-	for(n = 0;n<wordcnt;n++) {
-		wordno = total_words + n;
-		if((spacecnt = maxwordsize[n] - strlen(wordstor[wordno]))<0) {
-			sprintf(errstr,"Word alignment error: output_mixfile_line()\n");
-			return(PROGRAM_ERROR);
-		}
-		spacecnt++;
-		fprintf(dz->fp,"%s",wordstor[wordno]);
-		for(m=0;m<spacecnt;m++)
-			fprintf(dz->fp," ");
-	}
-	fprintf(dz->fp,"\n");
-	return(FINISHED);
+    int n, m, spacecnt;
+    int wordno;
+    for(n = 0;n<wordcnt;n++) {
+        wordno = total_words + n;
+        if((spacecnt = maxwordsize[n] - strlen(wordstor[wordno]))<0) {
+            sprintf(errstr,"Word alignment error: output_mixfile_line()\n");
+            return(PROGRAM_ERROR);
+        }
+        spacecnt++;
+        fprintf(dz->fp,"%s",wordstor[wordno]);
+        for(m=0;m<spacecnt;m++)
+            fprintf(dz->fp," ");
+    }
+    fprintf(dz->fp,"\n");
+    return(FINISHED);
 }
 }

+ 550 - 551
dev/submix/newmix0.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -60,283 +60,283 @@ static int  mirror_panning(char *thisword, int maxthiswordsize,dataptr dz);
 
 
 int mix_syntax_check(dataptr dz)
 int mix_syntax_check(dataptr dz)
 {
 {
-	int exit_status;
-	if((exit_status = syntax_check_mix(dz))<0)
-		return(exit_status);
-	if(exit_status==CONTINUE)
-		sprintf(errstr,"MIX SYNTAX IS CORRECT.\n");
-	return(FINISHED);
+    int exit_status;
+    if((exit_status = syntax_check_mix(dz))<0)
+        return(exit_status);
+    if(exit_status==CONTINUE)
+        sprintf(errstr,"MIX SYNTAX IS CORRECT.\n");
+    return(FINISHED);
 }
 }
 
 
 /********************** SYNTAX_CHECK_MIX ****************************/
 /********************** SYNTAX_CHECK_MIX ****************************/
- 
+
 int syntax_check_mix(dataptr dz)
 int syntax_check_mix(dataptr dz)
 {
 {
-	int    exit_status;
-	int    chans;
-	int   srate=0;
-	char   *filename;
-	int    filecnt = 0;												
-	int   total_words = 0, n;
-	if(dz->infile->filetype == MIXFILE)
-		return(CONTINUE);
-	if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
-		return(exit_status);
-	for(n=0;n<dz->linecnt;n++) {						/* for each mixfile line */
-		if(dz->wordstor[total_words][0]==';') {
-			total_words += dz->wordcnt[n];
-			continue;	
-		}	
-		filename = dz->wordstor[total_words];			/* get the filename */
-		if(strlen(filename)<=0) {
-			sprintf(errstr,"filename error: line %d\n",dz->linecnt+1);
-			return(FINISHED);
-		}
-		if((exit_status = test_mixdata_in_line(dz->wordcnt[n],dz->wordstor,total_words,&chans,n,dz))!=CONTINUE)
-			return(FINISHED);
-		total_words += dz->wordcnt[n];
-		if((exit_status = open_file_and_test_props(filecnt,filename,&srate,chans,n,dz))<0)
-			return(exit_status);
-		if(exit_status!=CONTINUE)
-			return(FINISHED);
-		filecnt++;											/* count the ACTUALLY USED lines: ignore comments */
-	}
-	if(filecnt==0) {
-		sprintf(errstr,"No active mixfile lines.\n");
-		return(FINISHED);
-	}
-	return(CONTINUE);
+    int    exit_status;
+    int    chans;
+    int   srate=0;
+    char   *filename;
+    int    filecnt = 0;
+    int   total_words = 0, n;
+    if(dz->infile->filetype == MIXFILE)
+        return(CONTINUE);
+    if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
+        return(exit_status);
+    for(n=0;n<dz->linecnt;n++) {                                            /* for each mixfile line */
+        if(dz->wordstor[total_words][0]==';') {
+            total_words += dz->wordcnt[n];
+            continue;
+        }
+        filename = dz->wordstor[total_words];                   /* get the filename */
+        if(strlen(filename)<=0) {
+            sprintf(errstr,"filename error: line %d\n",dz->linecnt+1);
+            return(FINISHED);
+        }
+        if((exit_status = test_mixdata_in_line(dz->wordcnt[n],dz->wordstor,total_words,&chans,n,dz))!=CONTINUE)
+            return(FINISHED);
+        total_words += dz->wordcnt[n];
+        if((exit_status = open_file_and_test_props(filecnt,filename,&srate,chans,n,dz))<0)
+            return(exit_status);
+        if(exit_status!=CONTINUE)
+            return(FINISHED);
+        filecnt++;                                                                                      /* count the ACTUALLY USED lines: ignore comments */
+    }
+    if(filecnt==0) {
+        sprintf(errstr,"No active mixfile lines.\n");
+        return(FINISHED);
+    }
+    return(CONTINUE);
 }
 }
 
 
 /**************************** TEST_MIXDATA_IN_LINE ********************************/
 /**************************** TEST_MIXDATA_IN_LINE ********************************/
 
 
 int test_mixdata_in_line(int wordcnt,char **wordstor,int total_words,int *chans,int lineno,dataptr dz)
 int test_mixdata_in_line(int wordcnt,char **wordstor,int total_words,int *chans,int lineno,dataptr dz)
 {
 {
-	int exit_status;
-	double time;
-	switch(wordcnt) {
-	case(MIX_MAXLINE):
-		if((exit_status = test_right_level(wordstor[total_words+MIX_RLEVELPOS],lineno))!=CONTINUE)	/* 6d */
-			return(FINISHED);
-		if((exit_status = test_right_pan(wordstor[total_words+MIX_RPANPOS],lineno))!=CONTINUE)
-			return(FINISHED);
-		/* fall thro */
-	case(MIX_MIDLINE):
-		if((exit_status = test_left_pan(wordstor[total_words+MIX_PANPOS],lineno))!=CONTINUE)		/* 6c */
-			return(FINISHED);
-		/* fall thro */
-	case(MIX_MINLINE):
-		if(sscanf(dz->wordstor[total_words+MIX_TIMEPOS],"%lf",&time)!=1)  {
-			sprintf(errstr,"Cannot read time data: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if(time < 0.0) {
-			sprintf(errstr,"time value less than 0.0 time: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if(sscanf(dz->wordstor[total_words+MIX_CHANPOS],"%d",chans)!=1) {
-			sprintf(errstr,"Cannot read channel data: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if(*chans < MONO || *chans > STEREO) {
-			sprintf(errstr,"channel value out of range: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if((exit_status = test_left_level(wordstor[total_words+MIX_LEVELPOS],lineno))!=CONTINUE)
-			return(FINISHED);
-		break;
-	default:
-		sprintf(errstr,"Illegal mixfile line-length: line %d\n",lineno+1);
-		return(FINISHED);
-	}
-	if(wordcnt==MIX_MIDLINE && *chans!=MONO) {
-		sprintf(errstr,"Invalid channel count, or line length: line %d\n",lineno+1);
-		return(FINISHED);
-	}
-	if(wordcnt==MIX_MAXLINE && *chans!=STEREO) {
-		sprintf(errstr,"Invalid channel count, or line too long: line %d\n",lineno+1);
-		return(FINISHED);
-	}
-	return(CONTINUE);
+    int exit_status;
+    double time;
+    switch(wordcnt) {
+    case(MIX_MAXLINE):
+        if((exit_status = test_right_level(wordstor[total_words+MIX_RLEVELPOS],lineno))!=CONTINUE)      /* 6d */
+            return(FINISHED);
+        if((exit_status = test_right_pan(wordstor[total_words+MIX_RPANPOS],lineno))!=CONTINUE)
+            return(FINISHED);
+        /* fall thro */
+    case(MIX_MIDLINE):
+        if((exit_status = test_left_pan(wordstor[total_words+MIX_PANPOS],lineno))!=CONTINUE)            /* 6c */
+            return(FINISHED);
+        /* fall thro */
+    case(MIX_MINLINE):
+        if(sscanf(dz->wordstor[total_words+MIX_TIMEPOS],"%lf",&time)!=1)  {
+            sprintf(errstr,"Cannot read time data: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if(time < 0.0) {
+            sprintf(errstr,"time value less than 0.0 time: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if(sscanf(dz->wordstor[total_words+MIX_CHANPOS],"%d",chans)!=1) {
+            sprintf(errstr,"Cannot read channel data: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if(*chans < MONO || *chans > STEREO) {
+            sprintf(errstr,"channel value out of range: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if((exit_status = test_left_level(wordstor[total_words+MIX_LEVELPOS],lineno))!=CONTINUE)
+            return(FINISHED);
+        break;
+    default:
+        sprintf(errstr,"Illegal mixfile line-length: line %d\n",lineno+1);
+        return(FINISHED);
+    }
+    if(wordcnt==MIX_MIDLINE && *chans!=MONO) {
+        sprintf(errstr,"Invalid channel count, or line length: line %d\n",lineno+1);
+        return(FINISHED);
+    }
+    if(wordcnt==MIX_MAXLINE && *chans!=STEREO) {
+        sprintf(errstr,"Invalid channel count, or line too long: line %d\n",lineno+1);
+        return(FINISHED);
+    }
+    return(CONTINUE);
 }
 }
 
 
 /************************** TEST_RIGHT_LEVEL ************************/
 /************************** TEST_RIGHT_LEVEL ************************/
 
 
 int test_right_level(char *str,int lineno)
 int test_right_level(char *str,int lineno)
 {
 {
-	double rlevel;
-	if(is_dB(str)) {
-		if(!get_leveldb(str,&rlevel)) {
-			sprintf(errstr,"Error in chan2 level: line %d\n",lineno+1);
-			return(FINISHED);
-		}		
-	} else {
-		if(sscanf(str,"%lf",&rlevel)!=1) {
-			sprintf(errstr,"Error2 in chan2 level: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-	}
-	if(rlevel < 0.0) {
-		sprintf(errstr,"chan2 level out of range: line %d\n",lineno+1);
-		return(FINISHED);
-	}
-	return(CONTINUE);
+    double rlevel;
+    if(is_dB(str)) {
+        if(!get_leveldb(str,&rlevel)) {
+            sprintf(errstr,"Error in chan2 level: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+    } else {
+        if(sscanf(str,"%lf",&rlevel)!=1) {
+            sprintf(errstr,"Error2 in chan2 level: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+    }
+    if(rlevel < 0.0) {
+        sprintf(errstr,"chan2 level out of range: line %d\n",lineno+1);
+        return(FINISHED);
+    }
+    return(CONTINUE);
 }
 }
 
 
 /*********************** TEST_RIGHT_PAN **********************/
 /*********************** TEST_RIGHT_PAN **********************/
 
 
 int test_right_pan(char *str,int lineno)
 int test_right_pan(char *str,int lineno)
 {
 {
-	double pan;
-	switch(str[0]) {
-	case('L'): 
-	case('R'): 
-	case('C'): return(CONTINUE);
-	default:
-		if(sscanf(str,"%lf",&pan)!=1) {
-			sprintf(errstr,"Error in chan2 pan: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if(pan < MINPAN || pan > MAXPAN)  {
-			sprintf(errstr,"chan2 pan out of range: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		break;
-	}
-	return(CONTINUE);
+    double pan;
+    switch(str[0]) {
+    case('L'):
+    case('R'):
+    case('C'): return(CONTINUE);
+    default:
+        if(sscanf(str,"%lf",&pan)!=1) {
+            sprintf(errstr,"Error in chan2 pan: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if(pan < MINPAN || pan > MAXPAN)  {
+            sprintf(errstr,"chan2 pan out of range: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        break;
+    }
+    return(CONTINUE);
 }
 }
 
 
 /*************** TEST_LEFT_LEVEL ******************/
 /*************** TEST_LEFT_LEVEL ******************/
 
 
 int test_left_level(char *str,int lineno)
 int test_left_level(char *str,int lineno)
 {
 {
-	double level;
-	if(is_dB(str)) {
-		if(!get_leveldb(str,&level)) {
-			sprintf(errstr,"Error in (chan1) level: line %d\n",lineno+1);
-			return(FINISHED);
-		}		
-	} else {
-		if(sscanf(str,"%lf",&level)!=1) {
-			sprintf(errstr,"Error in (chan1) level: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-	}
-	if(level < 0.0) {
-		sprintf(errstr,"(chan1) level out of range: line %d\n",lineno+1);
-		return(FINISHED);
-	}
-	return(CONTINUE);
+    double level;
+    if(is_dB(str)) {
+        if(!get_leveldb(str,&level)) {
+            sprintf(errstr,"Error in (chan1) level: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+    } else {
+        if(sscanf(str,"%lf",&level)!=1) {
+            sprintf(errstr,"Error in (chan1) level: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+    }
+    if(level < 0.0) {
+        sprintf(errstr,"(chan1) level out of range: line %d\n",lineno+1);
+        return(FINISHED);
+    }
+    return(CONTINUE);
 }
 }
 
 
 /************************** TEST_LEFT_PAN ************************/
 /************************** TEST_LEFT_PAN ************************/
 
 
 int test_left_pan(char *str,int lineno)
 int test_left_pan(char *str,int lineno)
 {
 {
-	double pan;
-	switch(str[0]) {
-	case('L'): 
-	case('R'): 
-	case('C'): return(CONTINUE);
-	default:
-		if(sscanf(str,"%lf",&pan)!=1) {
-			sprintf(errstr,"Error in (chan1) pan: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-		if(pan < MINPAN || pan > MAXPAN)  {
-			sprintf(errstr,"(chan1) pan out of range: line %d\n",lineno+1);
-			return(FINISHED);
-		}
-	}
-	return(CONTINUE);
+    double pan;
+    switch(str[0]) {
+    case('L'):
+    case('R'):
+    case('C'): return(CONTINUE);
+    default:
+        if(sscanf(str,"%lf",&pan)!=1) {
+            sprintf(errstr,"Error in (chan1) pan: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+        if(pan < MINPAN || pan > MAXPAN)  {
+            sprintf(errstr,"(chan1) pan out of range: line %d\n",lineno+1);
+            return(FINISHED);
+        }
+    }
+    return(CONTINUE);
 }
 }
 
 
 /************************* OPEN_FILE_AND_TEST_PROPS *******************************/
 /************************* OPEN_FILE_AND_TEST_PROPS *******************************/
 
 
 int open_file_and_test_props(int filecnt,char *filename,int *srate,int chans,int lineno,dataptr dz)
 int open_file_and_test_props(int filecnt,char *filename,int *srate,int chans,int lineno,dataptr dz)
 {
 {
-	int exit_status;
-	double maxamp, maxloc;
-	int maxrep;
-	int getmax = 0, getmaxinfo = 0;
-	infileptr ifp;
-	if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
-		return(MEMORY_ERROR);
-	}
-	if((dz->ifd[0] = sndopenEx(filename,0,CDP_OPEN_RDONLY)) < 0) {
-		sprintf(errstr,"Failed to open sndfile %s: line %d\n",filename,lineno+1);
-		return(FINISHED);
-	}
-	if((exit_status = readhead(ifp,dz->ifd[0],filename,&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
-		return(exit_status);
-	copy_to_fileptr(ifp,dz->infile);
-	if(dz->infile->filetype!=SNDFILE) {
-		sprintf(errstr,"%s is not a soundfile: line %d\n",filename,lineno+1);
-		return(FINISHED);
-	}
-	if(dz->infile->channels!=chans) {
-		sprintf(errstr,"channel-cnt in file '%s' different to channel value given: line %d\n",filename,lineno+1);
-		return(FINISHED);
-	}
-	if(filecnt==0)
-		*srate = dz->infile->srate;
-	else if(dz->infile->srate != *srate) {
-		sprintf(errstr,"incompatible srate: file %s: line %d\n",filename,lineno+1);
-		return(FINISHED);
-	}
-	if((dz->insams[0] = sndsizeEx(dz->ifd[0]))<0) {	    			
-		sprintf(errstr, "Can't read size of input file %s: line %d\n",filename,lineno+1);
-		return(PROGRAM_ERROR);
-	}
-	if(dz->insams[0] <=0) {
-		sprintf(errstr, "Zero size for input file %s: line %d\n",filename,lineno+1);
-		return(FINISHED);
-	}			
-	if(sndcloseEx(dz->ifd[0])<0) {
-		sprintf(errstr, "Failed to close input file %s: line %d\n",filename,lineno+1);
-		return(SYSTEM_ERROR);
-	}
-	dz->ifd[0] = -1;
-	return(CONTINUE);
+    int exit_status;
+    double maxamp, maxloc;
+    int maxrep;
+    int getmax = 0, getmaxinfo = 0;
+    infileptr ifp;
+    if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
+        return(MEMORY_ERROR);
+    }
+    if((dz->ifd[0] = sndopenEx(filename,0,CDP_OPEN_RDONLY)) < 0) {
+        sprintf(errstr,"Failed to open sndfile %s: line %d\n",filename,lineno+1);
+        return(FINISHED);
+    }
+    if((exit_status = readhead(ifp,dz->ifd[0],filename,&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
+        return(exit_status);
+    copy_to_fileptr(ifp,dz->infile);
+    if(dz->infile->filetype!=SNDFILE) {
+        sprintf(errstr,"%s is not a soundfile: line %d\n",filename,lineno+1);
+        return(FINISHED);
+    }
+    if(dz->infile->channels!=chans) {
+        sprintf(errstr,"channel-cnt in file '%s' different to channel value given: line %d\n",filename,lineno+1);
+        return(FINISHED);
+    }
+    if(filecnt==0)
+        *srate = dz->infile->srate;
+    else if(dz->infile->srate != *srate) {
+        sprintf(errstr,"incompatible srate: file %s: line %d\n",filename,lineno+1);
+        return(FINISHED);
+    }
+    if((dz->insams[0] = sndsizeEx(dz->ifd[0]))<0) {
+        sprintf(errstr, "Can't read size of input file %s: line %d\n",filename,lineno+1);
+        return(PROGRAM_ERROR);
+    }
+    if(dz->insams[0] <=0) {
+        sprintf(errstr, "Zero size for input file %s: line %d\n",filename,lineno+1);
+        return(FINISHED);
+    }
+    if(sndcloseEx(dz->ifd[0])<0) {
+        sprintf(errstr, "Failed to close input file %s: line %d\n",filename,lineno+1);
+        return(SYSTEM_ERROR);
+    }
+    dz->ifd[0] = -1;
+    return(CONTINUE);
 }
 }
 
 
 /********************** CREATE_MIXDUMMY ****************************/
 /********************** CREATE_MIXDUMMY ****************************/
- 
+
 int create_mixdummy(dataptr dz)
 int create_mixdummy(dataptr dz)
 {
 {
-	int    exit_status;
-	int   srate;
-	int	   this_namelen, max_namelen = 0;												
-	int   n;
-	double running_total = 0.0;
-	sndcloseEx(dz->ifd[0]);
-	dz->ifd[0] = -1;
-	if(dz->all_words==0) {
-		sprintf(errstr,"No words in source file.\n");
-		return(PROGRAM_ERROR);
-	}
-	dz->infilecnt = 1;		/* program now utilises only 1 file at a time : needs data storage for only 1 file */
-	if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
-		return(exit_status);
-	for(n=0;n<dz->all_words;n++) {						/* for each sndfile name */
-		if((this_namelen = strlen(dz->wordstor[n]))<=0) {
-			sprintf(errstr,"filename error: line %d\n",dz->linecnt+1);
-			return(PROGRAM_ERROR);
-		}
-		max_namelen = max(max_namelen,this_namelen);
-	}
-	for(n=0;n<dz->all_words;n++) {						/* for each sndfile name */
-		if((exit_status = open_file_and_retrieve_props(n,dz->wordstor[n],&srate,dz))<0)
-			return(exit_status);
-		if(dz->mode == 2 && dz->infile->channels != 1) {
-			sprintf(errstr,"This process only works with mono input files.\n");
-			return(DATA_ERROR);
-		}
-		if((exit_status = create_and_output_mixfile_line(n,max_namelen,&running_total,dz))<0)
-			return(exit_status);
-	}
-	return(FINISHED);
+    int    exit_status;
+    int   srate;
+    int        this_namelen, max_namelen = 0;
+    int   n;
+    double running_total = 0.0;
+    sndcloseEx(dz->ifd[0]);
+    dz->ifd[0] = -1;
+    if(dz->all_words==0) {
+        sprintf(errstr,"No words in source file.\n");
+        return(PROGRAM_ERROR);
+    }
+    dz->infilecnt = 1;              /* program now utilises only 1 file at a time : needs data storage for only 1 file */
+    if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
+        return(exit_status);
+    for(n=0;n<dz->all_words;n++) {                                          /* for each sndfile name */
+        if((this_namelen = strlen(dz->wordstor[n]))<=0) {
+            sprintf(errstr,"filename error: line %d\n",dz->linecnt+1);
+            return(PROGRAM_ERROR);
+        }
+        max_namelen = max(max_namelen,this_namelen);
+    }
+    for(n=0;n<dz->all_words;n++) {                                          /* for each sndfile name */
+        if((exit_status = open_file_and_retrieve_props(n,dz->wordstor[n],&srate,dz))<0)
+            return(exit_status);
+        if(dz->mode == 2 && dz->infile->channels != 1) {
+            sprintf(errstr,"This process only works with mono input files.\n");
+            return(DATA_ERROR);
+        }
+        if((exit_status = create_and_output_mixfile_line(n,max_namelen,&running_total,dz))<0)
+            return(exit_status);
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************* CREATE_AND_OUTPUT_MIXFILE_LINE *******************************/
 /************************* CREATE_AND_OUTPUT_MIXFILE_LINE *******************************/
@@ -344,342 +344,341 @@ int create_mixdummy(dataptr dz)
 //TW FUNCTION UPDATED (including flotsam conversion)
 //TW FUNCTION UPDATED (including flotsam conversion)
 int create_and_output_mixfile_line(int infilno,int max_namelen,double *running_total,dataptr dz)
 int create_and_output_mixfile_line(int infilno,int max_namelen,double *running_total,dataptr dz)
 {
 {
-	int space_count, n;
-	double filetime = 0.0; /* default value : MIXDUMMY , mode MD_TOGETHER */
-
-	if((space_count = max_namelen - strlen(dz->wordstor[infilno]))<0) {
-		sprintf(errstr,"Anomaly in space counting: create_and_output_mixfile_line()\n");
-		return(PROGRAM_ERROR);
-	}
-	space_count++;
-	fprintf(dz->fp,"%s",dz->wordstor[infilno]);
-	for(n=0;n<space_count;n++)
-		fprintf(dz->fp," ");
-	switch(dz->process) {
-	case(MIXDUMMY):
-		if(dz->mode == MD_FOLLOW) {
-			filetime = *running_total;
-			*running_total += (double)(dz->insams[0]/dz->infile->channels)/(double)dz->infile->srate;
-		}
-		break;			
-	case(MIX_ON_GRID):		
-		filetime = dz->parray[0][infilno];	
-		break;
-	case(MIX_AT_STEP):		
-			filetime = *running_total;
-			*running_total += dz->param[MIX_STEP];
-		break;
-	}
-	switch(dz->infile->channels) {
-	case(MONO):
-		if(dz->process == MIXDUMMY && dz->mode == 2) {
-			if(infilno == 0)
-				fprintf(dz->fp,"%.4lf  1  1.0  L\n",filetime);
-			else
-				fprintf(dz->fp,"%.4lf  1  1.0  R\n",filetime);
-		} else
-			fprintf(dz->fp,"%.4lf  1  1.0  C\n",filetime);
-		break;
-	case(STEREO):	fprintf(dz->fp,"%.4lf  2  1.0  L  1.0  R\n",filetime);	break;
-	default:
-		sprintf(errstr,"Invalid number of input channels for one of mix input files (Must be mono or stereo).\n");
-		return(DATA_ERROR);
-	}
-	return(FINISHED);
+    int space_count, n;
+    double filetime = 0.0; /* default value : MIXDUMMY , mode MD_TOGETHER */
+
+    if((space_count = max_namelen - strlen(dz->wordstor[infilno]))<0) {
+        sprintf(errstr,"Anomaly in space counting: create_and_output_mixfile_line()\n");
+        return(PROGRAM_ERROR);
+    }
+    space_count++;
+    fprintf(dz->fp,"%s",dz->wordstor[infilno]);
+    for(n=0;n<space_count;n++)
+        fprintf(dz->fp," ");
+    switch(dz->process) {
+    case(MIXDUMMY):
+        if(dz->mode == MD_FOLLOW) {
+            filetime = *running_total;
+            *running_total += (double)(dz->insams[0]/dz->infile->channels)/(double)dz->infile->srate;
+        }
+        break;
+    case(MIX_ON_GRID):
+        filetime = dz->parray[0][infilno];
+        break;
+    case(MIX_AT_STEP):
+        filetime = *running_total;
+        *running_total += dz->param[MIX_STEP];
+        break;
+    }
+    switch(dz->infile->channels) {
+    case(MONO):
+        if(dz->process == MIXDUMMY && dz->mode == 2) {
+            if(infilno == 0)
+                fprintf(dz->fp,"%.4lf  1  1.0  L\n",filetime);
+            else
+                fprintf(dz->fp,"%.4lf  1  1.0  R\n",filetime);
+        } else
+            fprintf(dz->fp,"%.4lf  1  1.0  C\n",filetime);
+        break;
+    case(STEREO):   fprintf(dz->fp,"%.4lf  2  1.0  L  1.0  R\n",filetime);  break;
+    default:
+        sprintf(errstr,"Invalid number of input channels for one of mix input files (Must be mono or stereo).\n");
+        return(DATA_ERROR);
+    }
+    return(FINISHED);
 }
 }
 
 
 /********************** OUTPUT_MIXFILE_LINE ****************************/
 /********************** OUTPUT_MIXFILE_LINE ****************************/
- 
+
 int output_mixfile_line(char **wordstor,int *maxwordsize,int start_word_no,int words_in_line,dataptr dz)
 int output_mixfile_line(char **wordstor,int *maxwordsize,int start_word_no,int words_in_line,dataptr dz)
 {
 {
-	int space_count, n, m;
-	int wordno;
-	for(n = 0;n < words_in_line; n++) {
-		wordno = start_word_no + n;
-		fprintf(dz->fp,"%s",wordstor[wordno]);
-		if((space_count = maxwordsize[n] - strlen(wordstor[wordno]))<0) {
-			sprintf(errstr,"Error in space_count: output_mixfile_line()\n");
-			return(PROGRAM_ERROR);
-		}
-		space_count++;
-		for(m=0; m < space_count;m++)
-			fprintf(dz->fp," ");
-	}
-	fprintf(dz->fp,"\n");
-	return(FINISHED);
+    int space_count, n, m;
+    int wordno;
+    for(n = 0;n < words_in_line; n++) {
+        wordno = start_word_no + n;
+        fprintf(dz->fp,"%s",wordstor[wordno]);
+        if((space_count = maxwordsize[n] - strlen(wordstor[wordno]))<0) {
+            sprintf(errstr,"Error in space_count: output_mixfile_line()\n");
+            return(PROGRAM_ERROR);
+        }
+        space_count++;
+        for(m=0; m < space_count;m++)
+            fprintf(dz->fp," ");
+    }
+    fprintf(dz->fp,"\n");
+    return(FINISHED);
 }
 }
 
 
 /********************** MIX_TWISTED ****************************/
 /********************** MIX_TWISTED ****************************/
- 
+
 int mix_twisted(dataptr dz)
 int mix_twisted(dataptr dz)
 {
 {
-	int    exit_status;
-	double time, llevel, lpan, rlevel, rpan;
-	int    chans, m;
-	int   n;
-	char   *filename;
-	int    filecnt = 0;												
-	int   total_words = 0, initial_total_words;
-	int    *maxwordsize;
-	if((maxwordsize = (int *)malloc(MIX_MAXLINE * sizeof(int)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store maximum word sizes.\n");
-		return(MEMORY_ERROR);
-	}
-	for(m=0;m<MIX_MAXLINE;m++)
-		maxwordsize[m] = 0;
-
-	for(n=0;n<dz->linecnt;n++) {						
-		filename = dz->wordstor[total_words];			
-		if(strlen(filename)<=0) {
-			free(maxwordsize);
-			sprintf(errstr,"filename error: line %d: mix_twisted()\n",filecnt+1);
-			return(PROGRAM_ERROR);
-		}
-		if((exit_status = get_mixdata_in_line			
-		(dz->wordcnt[n],dz->wordstor,total_words,&time,&chans,&llevel,&lpan,&rlevel,&rpan,filecnt,dz))<0) {
-			free(maxwordsize);
-			return(exit_status);
-		}
-		initial_total_words = total_words;
-		for(m=0;m<dz->wordcnt[n];m++)
-			maxwordsize[m] = (int)max((int)maxwordsize[m],(int)strlen(dz->wordstor[initial_total_words+m]));
-		total_words += dz->wordcnt[n];
-		if((exit_status = finalise_and_check_mixdata_in_line(dz->wordcnt[n],chans,llevel,&lpan,&rlevel,&rpan))<0) {
-			free(maxwordsize);
-			return(exit_status);
-		}
-		filecnt++;											
-	}
-	maxwordsize[MIX_PANPOS]   = (int)max((int)maxwordsize[MIX_PANPOS],(int)3);	/* allow pan to be converted text to number */
-	maxwordsize[MIX_RPANPOS]  = (int)max((int)maxwordsize[MIX_RPANPOS],(int)3);
-	maxwordsize[MIX_PANPOS]++;											/* allow for pan to become negative */
-	maxwordsize[MIX_RPANPOS]++;
-
-	total_words = 0;
-	filecnt = 0;
-	for(n=0;n<dz->linecnt;n++) {						
-		filename = dz->wordstor[total_words];			
-		initial_total_words = total_words;
-		total_words += dz->wordcnt[n];
-		switch(dz->mode) {
-		case(MSW_TWISTALL):
-			if(ODD(filecnt)) {
-				if((exit_status = twist_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
-					free(maxwordsize);
-					return(exit_status);
-				}
-			} else {
-				if((exit_status = output_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
-					free(maxwordsize);
-					return(exit_status);
-				}
-			}
-			break;
-		case(MSW_TWISTONE):
-			if(filecnt == dz->iparam[MSW_TWLINE]) {
- 				if((exit_status = twist_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
-					free(maxwordsize);
-					return(exit_status);
-				}
-			} else {
-				if((exit_status = output_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
-					free(maxwordsize);
-					return(exit_status);
-				}
-			}
-			break;
-		default:
-			sprintf(errstr,"Unknown mode in mix_twisted()\n");
-			return(PROGRAM_ERROR);
-		}
-		filecnt++;											
-	}
-
-	free(maxwordsize);
-	return(FINISHED);
+    int    exit_status;
+    double time, llevel, lpan, rlevel, rpan;
+    int    chans, m;
+    int   n;
+    char   *filename;
+    int    filecnt = 0;
+    int   total_words = 0, initial_total_words;
+    int    *maxwordsize;
+    if((maxwordsize = (int *)malloc(MIX_MAXLINE * sizeof(int)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store maximum word sizes.\n");
+        return(MEMORY_ERROR);
+    }
+    for(m=0;m<MIX_MAXLINE;m++)
+        maxwordsize[m] = 0;
+
+    for(n=0;n<dz->linecnt;n++) {
+        filename = dz->wordstor[total_words];
+        if(strlen(filename)<=0) {
+            free(maxwordsize);
+            sprintf(errstr,"filename error: line %d: mix_twisted()\n",filecnt+1);
+            return(PROGRAM_ERROR);
+        }
+        if((exit_status = get_mixdata_in_line
+            (dz->wordcnt[n],dz->wordstor,total_words,&time,&chans,&llevel,&lpan,&rlevel,&rpan,filecnt,dz))<0) {
+            free(maxwordsize);
+            return(exit_status);
+        }
+        initial_total_words = total_words;
+        for(m=0;m<dz->wordcnt[n];m++)
+            maxwordsize[m] = (int)max((int)maxwordsize[m],(int)strlen(dz->wordstor[initial_total_words+m]));
+        total_words += dz->wordcnt[n];
+        if((exit_status = finalise_and_check_mixdata_in_line(dz->wordcnt[n],chans,llevel,&lpan,&rlevel,&rpan))<0) {
+            free(maxwordsize);
+            return(exit_status);
+        }
+        filecnt++;
+    }
+    maxwordsize[MIX_PANPOS]   = (int)max((int)maxwordsize[MIX_PANPOS],(int)3);      /* allow pan to be converted text to number */
+    maxwordsize[MIX_RPANPOS]  = (int)max((int)maxwordsize[MIX_RPANPOS],(int)3);
+    maxwordsize[MIX_PANPOS]++;                                                                                      /* allow for pan to become negative */
+    maxwordsize[MIX_RPANPOS]++;
+
+    total_words = 0;
+    filecnt = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        filename = dz->wordstor[total_words];
+        initial_total_words = total_words;
+        total_words += dz->wordcnt[n];
+        switch(dz->mode) {
+        case(MSW_TWISTALL):
+            if(ODD(filecnt)) {
+                if((exit_status = twist_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
+                    free(maxwordsize);
+                    return(exit_status);
+                }
+            } else {
+                if((exit_status = output_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
+                    free(maxwordsize);
+                    return(exit_status);
+                }
+            }
+            break;
+        case(MSW_TWISTONE):
+            if(filecnt == dz->iparam[MSW_TWLINE]) {
+                if((exit_status = twist_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
+                    free(maxwordsize);
+                    return(exit_status);
+                }
+            } else {
+                if((exit_status = output_mixfile_line(dz->wordstor,maxwordsize,initial_total_words,dz->wordcnt[n],dz))<0) {
+                    free(maxwordsize);
+                    return(exit_status);
+                }
+            }
+            break;
+        default:
+            sprintf(errstr,"Unknown mode in mix_twisted()\n");
+            return(PROGRAM_ERROR);
+        }
+        filecnt++;
+    }
+
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /********************** TWIST_MIXFILE_LINE ****************************/
 /********************** TWIST_MIXFILE_LINE ****************************/
- 
+
 int twist_mixfile_line(char **wordstor,int *maxwordsize,int start_word_no,int words_in_line,dataptr dz)
 int twist_mixfile_line(char **wordstor,int *maxwordsize,int start_word_no,int words_in_line,dataptr dz)
 {
 {
-	int exit_status;
-	int n;
-	int wordno;
-	for(n = 0;n < words_in_line; n++) {
-		wordno = n + start_word_no;
-		switch(n) {
-		case(MIX_NAMEPOS):
-		case(MIX_TIMEPOS):
-		case(MIX_CHANPOS):
-		case(MIX_LEVELPOS):
-		case(MIX_RLEVELPOS):
-			if((exit_status = output_aligned_word(wordstor[wordno],maxwordsize[n],dz))<0)
-				return(exit_status);
-			break;
-		case(MIX_PANPOS):
-		case(MIX_RPANPOS):
-			if((exit_status = mirror_panning(wordstor[wordno],maxwordsize[n],dz))<0)
-				return(exit_status);
-			break;
-		default:
-			sprintf(errstr,"Impossible word no: twist_mixfile_line()\n");
-			return(PROGRAM_ERROR);
-		}
-	}   	
-	fprintf(dz->fp,"\n");
-	return(FINISHED);
+    int exit_status;
+    int n;
+    int wordno;
+    for(n = 0;n < words_in_line; n++) {
+        wordno = n + start_word_no;
+        switch(n) {
+        case(MIX_NAMEPOS):
+        case(MIX_TIMEPOS):
+        case(MIX_CHANPOS):
+        case(MIX_LEVELPOS):
+        case(MIX_RLEVELPOS):
+            if((exit_status = output_aligned_word(wordstor[wordno],maxwordsize[n],dz))<0)
+                return(exit_status);
+            break;
+        case(MIX_PANPOS):
+        case(MIX_RPANPOS):
+            if((exit_status = mirror_panning(wordstor[wordno],maxwordsize[n],dz))<0)
+                return(exit_status);
+            break;
+        default:
+            sprintf(errstr,"Impossible word no: twist_mixfile_line()\n");
+            return(PROGRAM_ERROR);
+        }
+    }
+    fprintf(dz->fp,"\n");
+    return(FINISHED);
 }
 }
 
 
 /********************** MIRROR_PANNING ****************************/
 /********************** MIRROR_PANNING ****************************/
- 
+
 int mirror_panning(char *thisword, int maxthiswordsize,dataptr dz)
 int mirror_panning(char *thisword, int maxthiswordsize,dataptr dz)
 {
 {
-	int exit_status;
-	double pan;
-	int was_neg = FALSE, newlen, leading_zero_cnt = 0;
-	char *p;
-	if(!strcmp(thisword,"C"))
-		return output_aligned_word(thisword,maxthiswordsize,dz);
-	else if(!strcmp(thisword,"L")) 
-		return output_aligned_word("R",maxthiswordsize,dz);
-	else if(!strcmp(thisword,"R"))
-		return output_aligned_word("L",maxthiswordsize,dz);
-	else if(sscanf(thisword,"%lf",&pan)!=1) {
-		sprintf(errstr,"Failed to get pan value 1: mirror_panning()\n");
-		return(PROGRAM_ERROR);
-	}
-	if(flteq(pan,0.0)) {
-		if((exit_status = output_aligned_word(thisword,maxthiswordsize,dz))<0)
-		return(exit_status);
-	} else {
-		if(pan < 0.0)
-			was_neg = TRUE;
-		pan = -pan;
-		sprintf(errstr,"%lf",pan);
-		newlen = strlen(thisword);
-		leading_zero_cnt = 0;
-		p = thisword;
-		if(was_neg)
-			p = thisword+1;
-		while(*p=='0') {
-			leading_zero_cnt++;
-			p++;
-		}
-		if(*p=='.') {
-			if(leading_zero_cnt==0)
-				newlen++;							/* Allow for leading 0 being added */
-			else
-				newlen -= leading_zero_cnt - 1;		/* Allow for xs leading zeroes being taken away */
-		}
-		if(was_neg)		newlen--;		/* Allow for decimal point being removed */
-		else			newlen++;		/* Allow for decimal point being added */
-		
-		*(errstr + newlen) = ENDOFSTR;
-		if((exit_status = output_aligned_word(errstr,maxthiswordsize,dz))<0)
-			return(exit_status);
-	}
-	return(FINISHED);
+    int exit_status;
+    double pan;
+    int was_neg = FALSE, newlen, leading_zero_cnt = 0;
+    char *p;
+    if(!strcmp(thisword,"C"))
+        return output_aligned_word(thisword,maxthiswordsize,dz);
+    else if(!strcmp(thisword,"L"))
+        return output_aligned_word("R",maxthiswordsize,dz);
+    else if(!strcmp(thisword,"R"))
+        return output_aligned_word("L",maxthiswordsize,dz);
+    else if(sscanf(thisword,"%lf",&pan)!=1) {
+        sprintf(errstr,"Failed to get pan value 1: mirror_panning()\n");
+        return(PROGRAM_ERROR);
+    }
+    if(flteq(pan,0.0)) {
+        if((exit_status = output_aligned_word(thisword,maxthiswordsize,dz))<0)
+            return(exit_status);
+    } else {
+        if(pan < 0.0)
+            was_neg = TRUE;
+        pan = -pan;
+        sprintf(errstr,"%lf",pan);
+        newlen = strlen(thisword);
+        leading_zero_cnt = 0;
+        p = thisword;
+        if(was_neg)
+            p = thisword+1;
+        while(*p=='0') {
+            leading_zero_cnt++;
+            p++;
+        }
+        if(*p=='.') {
+            if(leading_zero_cnt==0)
+                newlen++;                                                       /* Allow for leading 0 being added */
+            else
+                newlen -= leading_zero_cnt - 1;         /* Allow for xs leading zeroes being taken away */
+        }
+        if(was_neg)             newlen--;               /* Allow for decimal point being removed */
+        else                    newlen++;               /* Allow for decimal point being added */
+
+        *(errstr + newlen) = ENDOFSTR;
+        if((exit_status = output_aligned_word(errstr,maxthiswordsize,dz))<0)
+            return(exit_status);
+    }
+    return(FINISHED);
 }
 }
 
 
 /********************** OUTPUT_ALIGNED_WORD ****************************/
 /********************** OUTPUT_ALIGNED_WORD ****************************/
- 
+
 int output_aligned_word(char *thisword,int maxthiswordsize,dataptr dz)
 int output_aligned_word(char *thisword,int maxthiswordsize,dataptr dz)
 {
 {
-	int space_count, n;
-	fprintf(dz->fp,"%s",thisword);
-	if((space_count = maxthiswordsize - strlen(thisword))<0) {
-		sprintf(errstr,"Error in space_count: output_aligned_word()\n");
-		return(PROGRAM_ERROR);
-	}
-	space_count++;
-	for(n=0; n < space_count;n++)
-		fprintf(dz->fp," ");
-	return(FINISHED);
+    int space_count, n;
+    fprintf(dz->fp,"%s",thisword);
+    if((space_count = maxthiswordsize - strlen(thisword))<0) {
+        sprintf(errstr,"Error in space_count: output_aligned_word()\n");
+        return(PROGRAM_ERROR);
+    }
+    space_count++;
+    for(n=0; n < space_count;n++)
+        fprintf(dz->fp," ");
+    return(FINISHED);
 }
 }
 
 
 //TW UPDATE: NEW FUNCTION
 //TW UPDATE: NEW FUNCTION
 /********************** ADDTOMIX ****************************/
 /********************** ADDTOMIX ****************************/
- 
+
 int addtomix(dataptr dz)
 int addtomix(dataptr dz)
 {
 {
-	int    exit_status;
-	int	   total_wordcnt, *chans;												
-	int    n, m, sndfiles_in = dz->infilecnt - 1;
-	char	temp[200], temp2[200];
-	infileptr fq;
-	double maxamp, maxloc;
-	int maxrep;
-	int getmax = 0, getmaxinfo = 0;
-	if(sndfiles_in <= 0) {
-		sprintf(errstr,"No new sound files remembered.\n");
-		return(PROGRAM_ERROR);
-	}
-	if(dz->linecnt <= 0) {
-		sprintf(errstr,"None of original mixdata remembered.\n");
-		return(PROGRAM_ERROR);
-	}
-	if((fq = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
-		return(MEMORY_ERROR);
-	}
-	if ((chans = (int *)malloc(sndfiles_in * sizeof(int)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store channel count information.\n");
-		return(MEMORY_ERROR);
-	}
-	for(n = sndfiles_in,m = dz->all_words - 1; n>=1; n--,m--) {
-		if((exit_status = readhead(fq,dz->ifd[n],dz->wordstor[m],&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0) {
-			sprintf(errstr,"Cannot read header of soundfile %s\n",dz->wordstor[m]);
-			return(USER_ERROR);
-		}
-		if(((chans[n-1] = fq->channels) < 1) || (chans[n-1] > 2)) {
-			sprintf(errstr,"Soundfile %s has wrong number of channels [%d] for this process.\n",dz->wordstor[m],chans[n-1]);
-			return(DATA_ERROR);
-		}
-    }
-	
-	total_wordcnt = 0;
-	for(n=0;n< dz->linecnt;n++) {
-		for(m=0;m<dz->wordcnt[n];m++) {
-			if(m==0)
-				strcpy(temp,dz->wordstor[total_wordcnt++]);
-			else {
-				strcat(temp," ");
-				strcat(temp,dz->wordstor[total_wordcnt++]);
-			}
-			if(total_wordcnt >= dz->all_words) {
-				sprintf(errstr,"Word Count error.\n");
-				return(PROGRAM_ERROR);
-			}
-		}
-		strcat(temp,"\n");
-		if(fputs(temp,dz->fp)<0) {
-			sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
-			return(SYSTEM_ERROR);
-		}
-	}
-	m = 0;
-	while(total_wordcnt < dz->all_words) {
-		strcpy(temp,dz->wordstor[total_wordcnt]);
-		sprintf(temp2,"%lf",dz->duration);
-		strcat(temp," ");
-		strcat(temp,temp2);
-
-		if(chans[m] == 1)
-			strcat(temp,"  1 1.0 C\n");
-		else
-			strcat(temp," 2 1.0 L 1.0 R\n");
-		if(fputs(temp,dz->fp)<0) {
-			sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
-			return(SYSTEM_ERROR);
-		}
-		if(++total_wordcnt > dz->all_words) {
-			sprintf(errstr,"Word Count error.\n");
-			return(PROGRAM_ERROR);
-		}
-		m++;
-		n++;
-	}
-	return(FINISHED);
-}
+    int    exit_status;
+    int        total_wordcnt, *chans;
+    int    n, m, sndfiles_in = dz->infilecnt - 1;
+    char    temp[200], temp2[200];
+    infileptr fq;
+    double maxamp, maxloc;
+    int maxrep;
+    int getmax = 0, getmaxinfo = 0;
+    if(sndfiles_in <= 0) {
+        sprintf(errstr,"No new sound files remembered.\n");
+        return(PROGRAM_ERROR);
+    }
+    if(dz->linecnt <= 0) {
+        sprintf(errstr,"None of original mixdata remembered.\n");
+        return(PROGRAM_ERROR);
+    }
+    if((fq = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
+        return(MEMORY_ERROR);
+    }
+    if ((chans = (int *)malloc(sndfiles_in * sizeof(int)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store channel count information.\n");
+        return(MEMORY_ERROR);
+    }
+    for(n = sndfiles_in,m = dz->all_words - 1; n>=1; n--,m--) {
+        if((exit_status = readhead(fq,dz->ifd[n],dz->wordstor[m],&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0) {
+            sprintf(errstr,"Cannot read header of soundfile %s\n",dz->wordstor[m]);
+            return(USER_ERROR);
+        }
+        if(((chans[n-1] = fq->channels) < 1) || (chans[n-1] > 2)) {
+            sprintf(errstr,"Soundfile %s has wrong number of channels [%d] for this process.\n",dz->wordstor[m],chans[n-1]);
+            return(DATA_ERROR);
+        }
+    }
 
 
+    total_wordcnt = 0;
+    for(n=0;n< dz->linecnt;n++) {
+        for(m=0;m<dz->wordcnt[n];m++) {
+            if(m==0)
+                strcpy(temp,dz->wordstor[total_wordcnt++]);
+            else {
+                strcat(temp," ");
+                strcat(temp,dz->wordstor[total_wordcnt++]);
+            }
+            if(total_wordcnt >= dz->all_words) {
+                sprintf(errstr,"Word Count error.\n");
+                return(PROGRAM_ERROR);
+            }
+        }
+        strcat(temp,"\n");
+        if(fputs(temp,dz->fp)<0) {
+            sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
+            return(SYSTEM_ERROR);
+        }
+    }
+    m = 0;
+    while(total_wordcnt < dz->all_words) {
+        strcpy(temp,dz->wordstor[total_wordcnt]);
+        sprintf(temp2,"%lf",dz->duration);
+        strcat(temp," ");
+        strcat(temp,temp2);
+
+        if(chans[m] == 1)
+            strcat(temp,"  1 1.0 C\n");
+        else
+            strcat(temp," 2 1.0 L 1.0 R\n");
+        if(fputs(temp,dz->fp)<0) {
+            sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
+            return(SYSTEM_ERROR);
+        }
+        if(++total_wordcnt > dz->all_words) {
+            sprintf(errstr,"Word Count error.\n");
+            return(PROGRAM_ERROR);
+        }
+        m++;
+        n++;
+    }
+    return(FINISHED);
+}

File diff suppressed because it is too large
+ 479 - 479
dev/submix/newmix1.c


File diff suppressed because it is too large
+ 568 - 568
dev/submix/setupmix.c


+ 455 - 455
dev/submix/syncatt.c

@@ -1,24 +1,24 @@
 /*
 /*
- * 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
  *
  *
  This file is part of the CDP System.
  This file is part of the CDP System.
 
 
-    The CDP System is free software; you can redistribute it
-    and/or modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+ The CDP System is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
 
 
-    The CDP System is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Lesser General Public License for more details.
+ The CDP System is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
 
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with the CDP System; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-    02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with the CDP System; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
  *
  *
  */
  */
 
 
@@ -43,10 +43,10 @@
 #endif
 #endif
 
 
 static int  getenvpeak(int n,int samps_per_second,
 static int  getenvpeak(int n,int samps_per_second,
-			int windows_per_sector,int sectors_per_window,int window_size,dataptr dz);
+                       int windows_per_sector,int sectors_per_window,int window_size,dataptr dz);
 static int  gettime_of_maxsamp(int k, /*int*/float *env,/*int*/float *envend,int *envpos,int *peak_sampno,int window_size);
 static int  gettime_of_maxsamp(int k, /*int*/float *env,/*int*/float *envend,int *envpos,int *peak_sampno,int window_size);
 static int  create_envelope_arrays(int n,int numsects,int windows_per_sector,int sectors_per_window,
 static int  create_envelope_arrays(int n,int numsects,int windows_per_sector,int sectors_per_window,
-			int **envpos,/*int*/float **env,dataptr dz);
+                                   int **envpos,/*int*/float **env,dataptr dz);
 static int  count_sectors_to_scan(int *numsects,int lineno,int *skipsamps,int samps_per_second,dataptr dz);
 static int  count_sectors_to_scan(int *numsects,int lineno,int *skipsamps,int samps_per_second,dataptr dz);
 static int  get_envelope(int skipsamps,int **envpos,/*int*/float **env,int nbuff,int nsec, int window_size,dataptr dz);
 static int  get_envelope(int skipsamps,int **envpos,/*int*/float **env,int nbuff,int nsec, int window_size,dataptr dz);
 static void readenv_in_buffer(float *buf,int samps_to_process,int window_size,int **envpos,/*int*/float **env,int powflag);
 static void readenv_in_buffer(float *buf,int samps_to_process,int window_size,int **envpos,/*int*/float **env,int powflag);
@@ -66,62 +66,62 @@ static int  check_syncatt_window_factor(dataptr dz);
 //TW WINSECSIZE replaced by global F_SECSIZE
 //TW WINSECSIZE replaced by global F_SECSIZE
 int synchronise_mix_attack(dataptr dz)
 int synchronise_mix_attack(dataptr dz)
 {
 {
-	int    exit_status;
-	double total_maxval = 0.0, attenuation = 1.0, *timestor;
-	int   sectors_per_window, n,  max_atk_time = 0, sampblok, window_size;
-	int    windows_per_sector, typefactor, inchans;
-	int   total_words = 0, srate =0, samps_per_second;	
-	int    textfile_filetype = dz->infile->filetype;
-	for(n=0;n<dz->linecnt;n++) {
-		windows_per_sector = 0;
-		if((exit_status = open_file_retrieve_props_open(n,dz->wordstor[total_words],&srate,dz))<0)
-			return(exit_status);
-		inchans = dz->iparray[MSY_CHANS][n];
-		samps_per_second = srate * inchans;
-		typefactor       = dz->iparam[MSY_SRFAC] * inchans;
-		sampblok         = (F_SECSIZE  * typefactor)/dz->iparam[MSY_WFAC];
-		
-		if((sectors_per_window = sampblok/F_SECSIZE)<=0)
-			windows_per_sector = F_SECSIZE/sampblok;
-		window_size = sampblok;
-
-		if((exit_status = getenvpeak(n,samps_per_second,windows_per_sector,sectors_per_window,window_size,dz))<0)
-			return(exit_status);
-		if((exit_status = sum_maximum_samples(n,&total_maxval,dz))<0)	/* read maxsample and add to running sum */
-			return(exit_status);
-		dz->lparray[MSY_PEAKSAMP][n] /= inchans;	 					/* convert to 'stereo'-sample count: TRUNCATES */
-		max_atk_time = max(max_atk_time,dz->lparray[MSY_PEAKSAMP][n]);	/* find attack time which is latest */
-		total_words += dz->wordcnt[n];
-		if(sndcloseEx(dz->ifd[0])<0) {
-			sprintf(errstr, "Failed to close input file %s: line %d: synchronise_mix_attack()\n",
-			dz->wordstor[total_words],n+1);
-			return(SYSTEM_ERROR);
-		}
-		dz->ifd[0] = -1;
-	}
-	if(total_maxval > (double)F_MAXSAMP)									/* calculate required attenuation */
-		attenuation = (double)F_MAXSAMP/total_maxval;
-
-	if((dz->parray[MSY_TIMESTOR] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store times.\n");
-		return(MEMORY_ERROR);
-	}
-	timestor = dz->parray[MSY_TIMESTOR];
-	for(n=0;n<dz->linecnt;n++)											/* calculate sndfile offsets */
-		timestor[n] = (double)(max_atk_time - dz->lparray[MSY_PEAKSAMP][n])/(double)srate;
-
-	dz->infile->filetype = textfile_filetype;
-	switch(dz->infile->filetype) {
-	case(SNDLIST):
-	case(SYNCLIST):
-		return output_a_new_syncatt_file(timestor,attenuation,dz);
-	case(MIXFILE):
-		return output_a_syncatt_file(timestor,attenuation,dz);
-	default:
-		sprintf(errstr,"Unknown case in synchronise_mix_attack()\n");
-		return(PROGRAM_ERROR);
-	}
-	return(FINISHED);	/* NOTREACHED */
+    int    exit_status;
+    double total_maxval = 0.0, attenuation = 1.0, *timestor;
+    int   sectors_per_window, n,  max_atk_time = 0, sampblok, window_size;
+    int    windows_per_sector, typefactor, inchans;
+    int   total_words = 0, srate =0, samps_per_second;
+    int    textfile_filetype = dz->infile->filetype;
+    for(n=0;n<dz->linecnt;n++) {
+        windows_per_sector = 0;
+        if((exit_status = open_file_retrieve_props_open(n,dz->wordstor[total_words],&srate,dz))<0)
+            return(exit_status);
+        inchans = dz->iparray[MSY_CHANS][n];
+        samps_per_second = srate * inchans;
+        typefactor       = dz->iparam[MSY_SRFAC] * inchans;
+        sampblok         = (F_SECSIZE  * typefactor)/dz->iparam[MSY_WFAC];
+
+        if((sectors_per_window = sampblok/F_SECSIZE)<=0)
+            windows_per_sector = F_SECSIZE/sampblok;
+        window_size = sampblok;
+
+        if((exit_status = getenvpeak(n,samps_per_second,windows_per_sector,sectors_per_window,window_size,dz))<0)
+            return(exit_status);
+        if((exit_status = sum_maximum_samples(n,&total_maxval,dz))<0)   /* read maxsample and add to running sum */
+            return(exit_status);
+        dz->lparray[MSY_PEAKSAMP][n] /= inchans;                                                /* convert to 'stereo'-sample count: TRUNCATES */
+        max_atk_time = max(max_atk_time,dz->lparray[MSY_PEAKSAMP][n]);  /* find attack time which is latest */
+        total_words += dz->wordcnt[n];
+        if(sndcloseEx(dz->ifd[0])<0) {
+            sprintf(errstr, "Failed to close input file %s: line %d: synchronise_mix_attack()\n",
+                    dz->wordstor[total_words],n+1);
+            return(SYSTEM_ERROR);
+        }
+        dz->ifd[0] = -1;
+    }
+    if(total_maxval > (double)F_MAXSAMP)                                                                    /* calculate required attenuation */
+        attenuation = (double)F_MAXSAMP/total_maxval;
+
+    if((dz->parray[MSY_TIMESTOR] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store times.\n");
+        return(MEMORY_ERROR);
+    }
+    timestor = dz->parray[MSY_TIMESTOR];
+    for(n=0;n<dz->linecnt;n++)                                                                                      /* calculate sndfile offsets */
+        timestor[n] = (double)(max_atk_time - dz->lparray[MSY_PEAKSAMP][n])/(double)srate;
+
+    dz->infile->filetype = textfile_filetype;
+    switch(dz->infile->filetype) {
+    case(SNDLIST):
+    case(SYNCLIST):
+        return output_a_new_syncatt_file(timestor,attenuation,dz);
+    case(MIXFILE):
+        return output_a_syncatt_file(timestor,attenuation,dz);
+    default:
+        sprintf(errstr,"Unknown case in synchronise_mix_attack()\n");
+        return(PROGRAM_ERROR);
+    }
+    return(FINISHED);       /* NOTREACHED */
 }
 }
 
 
 /* RWD NB window_size is in samps */
 /* RWD NB window_size is in samps */
@@ -129,53 +129,53 @@ int synchronise_mix_attack(dataptr dz)
 /******************************** GETENVPEAK ******************************/
 /******************************** GETENVPEAK ******************************/
 
 
 int getenvpeak(int lineno,int samps_per_second,int windows_per_sector,int sectors_per_window,int window_size,dataptr dz)
 int getenvpeak(int lineno,int samps_per_second,int windows_per_sector,int sectors_per_window,int window_size,dataptr dz)
-{   
-	int exit_status;
-	int peak_sampno;
-	int skipsamps, numsects, searchsize, nbuff, nsec;
-	int  *envpos;
-	/*int*/float *env, *envend;
-	if((exit_status = count_sectors_to_scan(&numsects,lineno,&skipsamps,samps_per_second,dz))<0)
-		return(exit_status);
-	if((exit_status = create_envelope_arrays(lineno,numsects,windows_per_sector,sectors_per_window,&envpos,&env,dz))<0)
-		return(exit_status);
-	searchsize = numsects * F_SECSIZE;
-    nbuff      = searchsize/dz->buflen;	  			/* no. of whole buffs to srch   */
-    nsec       = (searchsize % dz->buflen)/F_SECSIZE;	/* no. of further secs to srch  */
-	if((exit_status = get_envelope(skipsamps,&envpos,&env,nbuff,nsec,window_size,dz))<0)
-		return(exit_status);
+{
+    int exit_status;
+    int peak_sampno;
+    int skipsamps, numsects, searchsize, nbuff, nsec;
+    int  *envpos;
+    /*int*/float *env, *envend;
+    if((exit_status = count_sectors_to_scan(&numsects,lineno,&skipsamps,samps_per_second,dz))<0)
+        return(exit_status);
+    if((exit_status = create_envelope_arrays(lineno,numsects,windows_per_sector,sectors_per_window,&envpos,&env,dz))<0)
+        return(exit_status);
+    searchsize = numsects * F_SECSIZE;
+    nbuff      = searchsize/dz->buflen;                         /* no. of whole buffs to srch   */
+    nsec       = (searchsize % dz->buflen)/F_SECSIZE;   /* no. of further secs to srch  */
+    if((exit_status = get_envelope(skipsamps,&envpos,&env,nbuff,nsec,window_size,dz))<0)
+        return(exit_status);
     envend   = env;
     envend   = env;
     env      = dz->lfarray[MSY_ENVEL];
     env      = dz->lfarray[MSY_ENVEL];
-	envpos   = dz->iparray[MSY_ENVPOS];
-	if((exit_status = gettime_of_maxsamp(lineno,env,envend,envpos,&peak_sampno,window_size))<0)
-		return(exit_status);
-	dz->lparray[MSY_PEAKSAMP][lineno] = peak_sampno + skipsamps;
-	return(FINISHED);
+    envpos   = dz->iparray[MSY_ENVPOS];
+    if((exit_status = gettime_of_maxsamp(lineno,env,envend,envpos,&peak_sampno,window_size))<0)
+        return(exit_status);
+    dz->lparray[MSY_PEAKSAMP][lineno] = peak_sampno + skipsamps;
+    return(FINISHED);
 }
 }
 
 
 /***************************** GETTIME_OF_MAXSAMP ***********************************/
 /***************************** GETTIME_OF_MAXSAMP ***********************************/
 
 
 int gettime_of_maxsamp(int lineno, /*int*/float *env,/*int*/float *envend,int *envpos,int *peak_sampno,int window_size)
 int gettime_of_maxsamp(int lineno, /*int*/float *env,/*int*/float *envend,int *envpos,int *peak_sampno,int window_size)
 {
 {
-	float peak = 0.0f, *thismax = env, *loudest_place = NULL;
-	
-	int  blokno;
-	while(thismax < envend) {
-		if(*thismax > peak) {
-			peak = *thismax;
-			loudest_place = thismax;
-		}
-		thismax++;
-	}
-	if(loudest_place==NULL) {
-		fprintf(stdout,"WARNING: No peak found in file %d: Syncing to file start.\n",lineno+1);
-		fflush(stdout);
-		*peak_sampno = 0;
-		return(FINISHED);
-	}
-	blokno       = loudest_place - env;           								/* to nearest shrtblok */
-	*peak_sampno = (blokno * window_size) + envpos[blokno]; 					/* to nearest sample   */
-	return(FINISHED);
+    float peak = 0.0f, *thismax = env, *loudest_place = NULL;
+
+    int  blokno;
+    while(thismax < envend) {
+        if(*thismax > peak) {
+            peak = *thismax;
+            loudest_place = thismax;
+        }
+        thismax++;
+    }
+    if(loudest_place==NULL) {
+        fprintf(stdout,"WARNING: No peak found in file %d: Syncing to file start.\n",lineno+1);
+        fflush(stdout);
+        *peak_sampno = 0;
+        return(FINISHED);
+    }
+    blokno       = loudest_place - env;                                                                     /* to nearest shrtblok */
+    *peak_sampno = (blokno * window_size) + envpos[blokno];                                         /* to nearest sample   */
+    return(FINISHED);
 }
 }
 
 
 /********************** CREATE_ENVELOPE_ARRAYS ***********************/
 /********************** CREATE_ENVELOPE_ARRAYS ***********************/
@@ -183,268 +183,268 @@ int gettime_of_maxsamp(int lineno, /*int*/float *env,/*int*/float *envend,int *e
 int create_envelope_arrays
 int create_envelope_arrays
 (int lineno,int numsects,int windows_per_sector,int sectors_per_window,int **envpos,/*int*/float **env,dataptr dz)
 (int lineno,int numsects,int windows_per_sector,int sectors_per_window,int **envpos,/*int*/float **env,dataptr dz)
 {
 {
-	int arraysize;
-	if(windows_per_sector > 0) {
-		arraysize = numsects * windows_per_sector;
-		arraysize += windows_per_sector;  /* Allow for a short buf at end */
-	} else {
-		arraysize = numsects/sectors_per_window;
-		arraysize++;		           /* round up + allow ditto */
-	}
-	if(lineno==0) {
-		if((dz->iparray[MSY_ENVPOS] = (int *)malloc(arraysize * sizeof(int)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY to store envelope positions.\n");
-			return(MEMORY_ERROR);
-		}
-		if((dz->lfarray[MSY_ENVEL] = (/*int*/float *)malloc(arraysize * sizeof(/*int*/float)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY to store envelope.\n");
-			return(MEMORY_ERROR);
-		}
-	} else {
-		free(dz->iparray[MSY_ENVPOS]);
-		free(dz->lparray[MSY_ENVEL]);
-		dz->iparray[MSY_ENVPOS] = NULL;
-		dz->lparray[MSY_ENVEL]  = NULL;
-		if((dz->iparray[MSY_ENVPOS] = (int *)realloc(dz->iparray[MSY_ENVPOS],arraysize * sizeof(int)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY to reallocate envelope positions.\n");
-			return(MEMORY_ERROR);
-		}
-		if((dz->lfarray[MSY_ENVEL] = (/*int*/float *)realloc(dz->lfarray[MSY_ENVEL],arraysize * sizeof(/*int*/float)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY to reallocate envelope.\n");
-			return(MEMORY_ERROR);
-		}
-	}
-	*envpos = dz->iparray[MSY_ENVPOS];
-	*env    = dz->lfarray[MSY_ENVEL];
-	return(FINISHED);
+    int arraysize;
+    if(windows_per_sector > 0) {
+        arraysize = numsects * windows_per_sector;
+        arraysize += windows_per_sector;  /* Allow for a short buf at end */
+    } else {
+        arraysize = numsects/sectors_per_window;
+        arraysize++;                       /* round up + allow ditto */
+    }
+    if(lineno==0) {
+        if((dz->iparray[MSY_ENVPOS] = (int *)malloc(arraysize * sizeof(int)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY to store envelope positions.\n");
+            return(MEMORY_ERROR);
+        }
+        if((dz->lfarray[MSY_ENVEL] = (/*int*/float *)malloc(arraysize * sizeof(/*int*/float)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY to store envelope.\n");
+            return(MEMORY_ERROR);
+        }
+    } else {
+        free(dz->iparray[MSY_ENVPOS]);
+        free(dz->lparray[MSY_ENVEL]);
+        dz->iparray[MSY_ENVPOS] = NULL;
+        dz->lparray[MSY_ENVEL]  = NULL;
+        if((dz->iparray[MSY_ENVPOS] = (int *)realloc(dz->iparray[MSY_ENVPOS],arraysize * sizeof(int)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY to reallocate envelope positions.\n");
+            return(MEMORY_ERROR);
+        }
+        if((dz->lfarray[MSY_ENVEL] = (/*int*/float *)realloc(dz->lfarray[MSY_ENVEL],arraysize * sizeof(/*int*/float)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY to reallocate envelope.\n");
+            return(MEMORY_ERROR);
+        }
+    }
+    *envpos = dz->iparray[MSY_ENVPOS];
+    *env    = dz->lfarray[MSY_ENVEL];
+    return(FINISHED);
 }
 }
 
 
 /****************************** COUNT_SECTORS_TO_SCAN *******************************/
 /****************************** COUNT_SECTORS_TO_SCAN *******************************/
 
 
 int count_sectors_to_scan(int *numsects,int lineno,int *skipsamps,int samps_per_second,dataptr dz)
 int count_sectors_to_scan(int *numsects,int lineno,int *skipsamps,int samps_per_second,dataptr dz)
 {
 {
-	int endsamps, endsecs, skipsecs;
-	double *start = dz->parray[MSY_STARTSRCH];
-	double *end   = dz->parray[MSY_ENDSRCH];
-	int shsecsize = F_SECSIZE;
-	skipsecs   = 0;
-	/* RWD what is this doing? */
-	*skipsamps = round(start[lineno] * (double)samps_per_second);
-//TW SAFETY for the moment: matches up with secsize rounding  below
-// and secsize rounding in envelope-windowing and search
-	skipsecs   = *skipsamps/shsecsize;		/* TRUNCATE */
-	*skipsamps = skipsecs * shsecsize;   
-
-	if(end[lineno] < 0.0)						/* -1.0 flags ENDOFSNDFILE */
-		endsamps = dz->lparray[MSY_SAMPSIZE][lineno];
-	else
-		endsamps = round(end[lineno] * samps_per_second);
-	endsecs  = endsamps/shsecsize;
-	if(endsecs * shsecsize < endsamps)		/* CEILING */
-		endsecs++;
-	*numsects = max((int)1,endsecs - skipsecs);
-	return(FINISHED);
+    int endsamps, endsecs, skipsecs;
+    double *start = dz->parray[MSY_STARTSRCH];
+    double *end   = dz->parray[MSY_ENDSRCH];
+    int shsecsize = F_SECSIZE;
+    skipsecs   = 0;
+    /* RWD what is this doing? */
+    *skipsamps = round(start[lineno] * (double)samps_per_second);
+    //TW SAFETY for the moment: matches up with secsize rounding  below
+    // and secsize rounding in envelope-windowing and search
+    skipsecs   = *skipsamps/shsecsize;              /* TRUNCATE */
+    *skipsamps = skipsecs * shsecsize;
+
+    if(end[lineno] < 0.0)                                           /* -1.0 flags ENDOFSNDFILE */
+        endsamps = dz->lparray[MSY_SAMPSIZE][lineno];
+    else
+        endsamps = round(end[lineno] * samps_per_second);
+    endsecs  = endsamps/shsecsize;
+    if(endsecs * shsecsize < endsamps)              /* CEILING */
+        endsecs++;
+    *numsects = max((int)1,endsecs - skipsecs);
+    return(FINISHED);
 }
 }
 
 
 /************************** GET_ENVELOPE ***************************/
 /************************** GET_ENVELOPE ***************************/
 
 
 int get_envelope(int skipsamps,int **envpos,/*int*/float **env,int nbuff,int nsec, int window_size,dataptr dz)
 int get_envelope(int skipsamps,int **envpos,/*int*/float **env,int nbuff,int nsec, int window_size,dataptr dz)
 {
 {
-	int  exit_status;
-	int n, shrtstoget;
-	int shsecsize = F_SECSIZE;
-	float *buf = dz->sampbuf[0];
-	int powflag = dz->vflag[MSY_POWMETHOD];
-	if(sndseekEx(dz->ifd[0],skipsamps,0)<0) {
-		sprintf(errstr,"seek() failed in get_envelope()\n");
-		return(SYSTEM_ERROR);
-	}
-	if(nbuff > 0) {
-		for(n = 0; n < nbuff-1; n++)	{			/* 1ST PASS : WHOLE BUFFERS */
-			if((exit_status = read_samps(dz->bigbuf,dz))<0)
-				return(exit_status);
-			if(dz->ssampsread < dz->buflen) {
-				sprintf(errstr,"Error in buffer accounting: get_envelope()\n");
-				return(PROGRAM_ERROR);
-			}
-			readenv_in_buffer(buf,dz->buflen,window_size,envpos,env,powflag);
-		}
-												/* 2ND PASS : LAST WHOLE BUFFERS */
-		if((exit_status = read_samps(dz->bigbuf,dz))<0)
-			return(exit_status);
-		if(nsec > 0 && dz->ssampsread < dz->buflen) {
-			sprintf(errstr,"Error in buffer accounting: get_envelope()\n");
-			return(PROGRAM_ERROR);
-		}
-		readenv_in_buffer(buf,min(dz->ssampsread,dz->buflen),window_size,envpos,env,powflag);
-	}
-
-	if(nsec) {									/* 3RD PASS : REMAINING SECTORS */
-		shrtstoget = nsec * shsecsize;
-		if((exit_status = read_samps(dz->bigbuf,dz))<0)
-			return(exit_status);
-		readenv_in_buffer(buf,min(shrtstoget,dz->ssampsread),window_size,envpos,env,powflag);
-	}
-	return(FINISHED);
+    int  exit_status;
+    int n, shrtstoget;
+    int shsecsize = F_SECSIZE;
+    float *buf = dz->sampbuf[0];
+    int powflag = dz->vflag[MSY_POWMETHOD];
+    if(sndseekEx(dz->ifd[0],skipsamps,0)<0) {
+        sprintf(errstr,"seek() failed in get_envelope()\n");
+        return(SYSTEM_ERROR);
+    }
+    if(nbuff > 0) {
+        for(n = 0; n < nbuff-1; n++)    {                       /* 1ST PASS : WHOLE BUFFERS */
+            if((exit_status = read_samps(dz->bigbuf,dz))<0)
+                return(exit_status);
+            if(dz->ssampsread < dz->buflen) {
+                sprintf(errstr,"Error in buffer accounting: get_envelope()\n");
+                return(PROGRAM_ERROR);
+            }
+            readenv_in_buffer(buf,dz->buflen,window_size,envpos,env,powflag);
+        }
+        /* 2ND PASS : LAST WHOLE BUFFERS */
+        if((exit_status = read_samps(dz->bigbuf,dz))<0)
+            return(exit_status);
+        if(nsec > 0 && dz->ssampsread < dz->buflen) {
+            sprintf(errstr,"Error in buffer accounting: get_envelope()\n");
+            return(PROGRAM_ERROR);
+        }
+        readenv_in_buffer(buf,min(dz->ssampsread,dz->buflen),window_size,envpos,env,powflag);
+    }
+
+    if(nsec) {                                                                      /* 3RD PASS : REMAINING SECTORS */
+        shrtstoget = nsec * shsecsize;
+        if((exit_status = read_samps(dz->bigbuf,dz))<0)
+            return(exit_status);
+        readenv_in_buffer(buf,min(shrtstoget,dz->ssampsread),window_size,envpos,env,powflag);
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************* READENV_IN_BUFFER ******************************/
 /************************* READENV_IN_BUFFER ******************************/
 
 
 void readenv_in_buffer(float *buf,int samps_to_process,int window_size,int **envpos,/*int*/float **env,int powflag)
 void readenv_in_buffer(float *buf,int samps_to_process,int window_size,int **envpos,/*int*/float **env,int powflag)
 {
 {
-	int  startsamp = 0;
-	int  *epos;
-	float *ev;
-	epos  = *envpos;
-	ev    = *env;
-	while(samps_to_process >= window_size) {
-		getmaxsamp_in_window(buf,startsamp,window_size,epos,ev,powflag);
-		epos++;
-		ev++;
-		startsamp 		 += window_size;
-		samps_to_process -= window_size;
-	}
-	if(samps_to_process) {	/* Handle any final short buffer */
-		getmaxsamp_in_window(buf,startsamp,samps_to_process,epos,ev,powflag);
-		epos++;
-		ev++;
-	}
-	*envpos = epos;
-	*env    = ev;
+    int  startsamp = 0;
+    int  *epos;
+    float *ev;
+    epos  = *envpos;
+    ev    = *env;
+    while(samps_to_process >= window_size) {
+        getmaxsamp_in_window(buf,startsamp,window_size,epos,ev,powflag);
+        epos++;
+        ev++;
+        startsamp                += window_size;
+        samps_to_process -= window_size;
+    }
+    if(samps_to_process) {  /* Handle any final short buffer */
+        getmaxsamp_in_window(buf,startsamp,samps_to_process,epos,ev,powflag);
+        epos++;
+        ev++;
+    }
+    *envpos = epos;
+    *env    = ev;
 }
 }
 
 
 /*************************** GETMAXSAMP_IN_WINDOW ********************************/
 /*************************** GETMAXSAMP_IN_WINDOW ********************************/
 
 
 void getmaxsamp_in_window(float *buf,int startsamp,int sample_cnt,int *envpos, /*int*/float *env,int powflag)
 void getmaxsamp_in_window(float *buf,int startsamp,int sample_cnt,int *envpos, /*int*/float *env,int powflag)
 {
 {
-	int   i, endsamp = startsamp + sample_cnt, maxpos = startsamp;
-	double rms_power = 0.0;
-	double maxval = 0, val;
-	
-
-	switch(powflag) {			
-	case(TRUE):
-		for(i = startsamp; i<endsamp; i++) {
-			val = fabs(buf[i]);
-			rms_power += (double)(val * val);
-			if(val > maxval) {
-				maxval = val;
-				maxpos = i;
-			}
-		}
-		rms_power /= (double)sample_cnt;
-		rms_power  = sqrt(rms_power);
-		*env       = (float) rms_power;
-		break;
-	case(FALSE):
-		for(i = startsamp; i<endsamp; i++) {
-			val = fabs(buf[i]);
-			if(val > maxval) {
-				maxval = val;
-				maxpos = i;
-			}
-		}
-		*env = (float)maxval;
-		break;
-	}
-	*envpos = (int)(maxpos - startsamp);
+    int   i, endsamp = startsamp + sample_cnt, maxpos = startsamp;
+    double rms_power = 0.0;
+    double maxval = 0, val;
+
+
+    switch(powflag) {
+    case(TRUE):
+        for(i = startsamp; i<endsamp; i++) {
+            val = fabs(buf[i]);
+            rms_power += (double)(val * val);
+            if(val > maxval) {
+                maxval = val;
+                maxpos = i;
+            }
+        }
+        rms_power /= (double)sample_cnt;
+        rms_power  = sqrt(rms_power);
+        *env       = (float) rms_power;
+        break;
+    case(FALSE):
+        for(i = startsamp; i<endsamp; i++) {
+            val = fabs(buf[i]);
+            if(val > maxval) {
+                maxval = val;
+                maxpos = i;
+            }
+        }
+        *env = (float)maxval;
+        break;
+    }
+    *envpos = (int)(maxpos - startsamp);
 }
 }
 
 
 /*************************** RESCALE_THE_LINES ***************************/
 /*************************** RESCALE_THE_LINES ***************************/
 
 
 int rescale_the_lines(double atten,dataptr dz)
 int rescale_the_lines(double atten,dataptr dz)
 {
 {
-	int exit_status;
-	int lineno;
-	int total_words = 0;
-	for(lineno=0;lineno<dz->linecnt;lineno++) {
-		if((exit_status = attenuate_line(total_words,atten,dz->wordcnt[lineno],dz))<0)
-			return(exit_status);
-		total_words += dz->wordcnt[lineno];
-	}
-	return(FINISHED);
+    int exit_status;
+    int lineno;
+    int total_words = 0;
+    for(lineno=0;lineno<dz->linecnt;lineno++) {
+        if((exit_status = attenuate_line(total_words,atten,dz->wordcnt[lineno],dz))<0)
+            return(exit_status);
+        total_words += dz->wordcnt[lineno];
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************** ATTENUATE_LINE ***************************/
 /************************** ATTENUATE_LINE ***************************/
 
 
 int attenuate_line(int total_words,double atten,int wordcnt,dataptr dz)
 int attenuate_line(int total_words,double atten,int wordcnt,dataptr dz)
 {
 {
-	int    exit_status;
-	int   wordno, newlen;
-	double level;
-	wordno = total_words + MIX_LEVELPOS;
-	if((exit_status = get_level(dz->wordstor[wordno],&level))<0)
-		return(exit_status);
-	sprintf(errstr,"%.5lf",level * atten);
-	if((newlen = (int)strlen(errstr)) > (int)strlen(dz->wordstor[wordno])) {
-		if((dz->wordstor[wordno] = (char *)realloc(dz->wordstor[wordno],(newlen+1) * sizeof(char)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY for wordstore %d\n",wordno+1);
-			return(MEMORY_ERROR);
-		}
-	}
-	strcpy(dz->wordstor[wordno],errstr);
-	if(wordcnt <= MIX_MIDLINE)
-		return(FINISHED);
-
-	wordno = total_words + MIX_RLEVELPOS;
-	if((exit_status = get_level(dz->wordstor[wordno],&level))<0)
-		return(exit_status);
-	sprintf(errstr,"%.5lf",level * atten);
-	if((newlen = (int)strlen(errstr)) > (int)strlen(dz->wordstor[wordno])) {
-		if((dz->wordstor[wordno] = (char *)realloc(dz->wordstor[wordno],(newlen+1) * sizeof(char)))==NULL) {
-			sprintf(errstr,"INSUFFICIENT MEMORY for wordstore %d\n",wordno+1);
-			return(MEMORY_ERROR);
-		}
-	}
-	strcpy(dz->wordstor[wordno],errstr);
-	return(FINISHED);
+    int    exit_status;
+    int   wordno, newlen;
+    double level;
+    wordno = total_words + MIX_LEVELPOS;
+    if((exit_status = get_level(dz->wordstor[wordno],&level))<0)
+        return(exit_status);
+    sprintf(errstr,"%.5lf",level * atten);
+    if((newlen = (int)strlen(errstr)) > (int)strlen(dz->wordstor[wordno])) {
+        if((dz->wordstor[wordno] = (char *)realloc(dz->wordstor[wordno],(newlen+1) * sizeof(char)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY for wordstore %d\n",wordno+1);
+            return(MEMORY_ERROR);
+        }
+    }
+    strcpy(dz->wordstor[wordno],errstr);
+    if(wordcnt <= MIX_MIDLINE)
+        return(FINISHED);
+
+    wordno = total_words + MIX_RLEVELPOS;
+    if((exit_status = get_level(dz->wordstor[wordno],&level))<0)
+        return(exit_status);
+    sprintf(errstr,"%.5lf",level * atten);
+    if((newlen = (int)strlen(errstr)) > (int)strlen(dz->wordstor[wordno])) {
+        if((dz->wordstor[wordno] = (char *)realloc(dz->wordstor[wordno],(newlen+1) * sizeof(char)))==NULL) {
+            sprintf(errstr,"INSUFFICIENT MEMORY for wordstore %d\n",wordno+1);
+            return(MEMORY_ERROR);
+        }
+    }
+    strcpy(dz->wordstor[wordno],errstr);
+    return(FINISHED);
 }
 }
 
 
 /************************** OUTPUT_A_NEW_SYNCATT_FILE ***************************/
 /************************** OUTPUT_A_NEW_SYNCATT_FILE ***************************/
 
 
 int output_a_new_syncatt_file(double *timestor,double gain,dataptr dz)
 int output_a_new_syncatt_file(double *timestor,double gain,dataptr dz)
 {
 {
-	int  exit_status;
-	int  max_timeword = 0;
-	int  max_namelen  = 0;
-	int total_words  = 0, n;
-	for(n=0;n<dz->linecnt;n++) {
-		max_namelen = max(max_namelen,(int)strlen(dz->wordstor[total_words]));
-		sprintf(errstr,"%.5lf",timestor[n]);
-		max_timeword = max(max_timeword,(int)strlen(errstr));
-		total_words += dz->wordcnt[n];
-	}							
-	total_words = 0;
-	for(n=0;n<dz->linecnt;n++) {						
-		if((exit_status = sync_and_output_mixfile_line
-		(n,dz->wordstor[total_words],max_namelen,max_timeword,timestor[n],gain,dz))<0)
-			return(exit_status);
-		total_words += dz->wordcnt[n];
-	}
-	return(FINISHED);
+    int  exit_status;
+    int  max_timeword = 0;
+    int  max_namelen  = 0;
+    int total_words  = 0, n;
+    for(n=0;n<dz->linecnt;n++) {
+        max_namelen = max(max_namelen,(int)strlen(dz->wordstor[total_words]));
+        sprintf(errstr,"%.5lf",timestor[n]);
+        max_timeword = max(max_timeword,(int)strlen(errstr));
+        total_words += dz->wordcnt[n];
+    }
+    total_words = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        if((exit_status = sync_and_output_mixfile_line
+            (n,dz->wordstor[total_words],max_namelen,max_timeword,timestor[n],gain,dz))<0)
+            return(exit_status);
+        total_words += dz->wordcnt[n];
+    }
+    return(FINISHED);
 }
 }
 
 
 /************************** OUTPUT_A_SYNCATT_FILE ***************************/
 /************************** OUTPUT_A_SYNCATT_FILE ***************************/
 
 
 int output_a_syncatt_file(double *timestor,double gain,dataptr dz)
 int output_a_syncatt_file(double *timestor,double gain,dataptr dz)
 {
 {
-	int exit_status;
-	int *maxwordsize;
-	int postdec = DEFAULT_DECIMAL_REPRESENTATION;
-	if((exit_status = retime_the_lines(timestor,postdec,dz))<0)
-		return(exit_status);
-	if(gain < 1.0) {
-		if((exit_status = rescale_the_lines(gain,dz))<0)
-			return(exit_status);
-	}
-	if((exit_status = timesort_mixfile(timestor,dz))<0)
-		return(exit_status);
-	if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
-		return(exit_status);
-	if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
-		return(exit_status);
-	free(maxwordsize);
-	return(FINISHED);
+    int exit_status;
+    int *maxwordsize;
+    int postdec = DEFAULT_DECIMAL_REPRESENTATION;
+    if((exit_status = retime_the_lines(timestor,postdec,dz))<0)
+        return(exit_status);
+    if(gain < 1.0) {
+        if((exit_status = rescale_the_lines(gain,dz))<0)
+            return(exit_status);
+    }
+    if((exit_status = timesort_mixfile(timestor,dz))<0)
+        return(exit_status);
+    if((exit_status = get_maxwordsize(&maxwordsize,dz))<0)
+        return(exit_status);
+    if((exit_status = output_mixfile_lines(maxwordsize,dz))<0)
+        return(exit_status);
+    free(maxwordsize);
+    return(FINISHED);
 }
 }
 
 
 /************************** SUM_MAXIMUM_SAMPLES ***************************/
 /************************** SUM_MAXIMUM_SAMPLES ***************************/
@@ -452,152 +452,152 @@ int output_a_syncatt_file(double *timestor,double gain,dataptr dz)
 
 
 int sum_maximum_samples(int n,double *total_maxval,dataptr dz)
 int sum_maximum_samples(int n,double *total_maxval,dataptr dz)
 {
 {
-	int   exit_status;
-	float *buf = dz->sampbuf[0];
-	int  shsecsize = F_SECSIZE;
-	int  peak_sampno = dz->lparray[MSY_PEAKSAMP][n];
-	int  sectorstart_of_maxsamp, sampstep;
-
-	sectorstart_of_maxsamp = (peak_sampno/shsecsize) * shsecsize;	 /* TRUNCATE */
-	sampstep  = peak_sampno - sectorstart_of_maxsamp;
-	if(sndseekEx(dz->ifd[0],sectorstart_of_maxsamp,0)<0) {
-		sprintf(errstr,"soundfile seek failed in sum_maximum_samples()\n");
-		return(SYSTEM_ERROR);
-	}
-	if((exit_status = read_samps(buf,dz))<0)
-		return(exit_status);
-	if(sampstep >= dz->ssampsread) {
-		sprintf(errstr,"Buffer accounting anomaly: sum_maximum_samples()\n");
-		return(PROGRAM_ERROR);
-	}
-	*total_maxval +=  fabs(buf[sampstep]);
-	return(FINISHED);
+    int   exit_status;
+    float *buf = dz->sampbuf[0];
+    int  shsecsize = F_SECSIZE;
+    int  peak_sampno = dz->lparray[MSY_PEAKSAMP][n];
+    int  sectorstart_of_maxsamp, sampstep;
+
+    sectorstart_of_maxsamp = (peak_sampno/shsecsize) * shsecsize;    /* TRUNCATE */
+    sampstep  = peak_sampno - sectorstart_of_maxsamp;
+    if(sndseekEx(dz->ifd[0],sectorstart_of_maxsamp,0)<0) {
+        sprintf(errstr,"soundfile seek failed in sum_maximum_samples()\n");
+        return(SYSTEM_ERROR);
+    }
+    if((exit_status = read_samps(buf,dz))<0)
+        return(exit_status);
+    if(sampstep >= dz->ssampsread) {
+        sprintf(errstr,"Buffer accounting anomaly: sum_maximum_samples()\n");
+        return(PROGRAM_ERROR);
+    }
+    *total_maxval +=  fabs(buf[sampstep]);
+    return(FINISHED);
 }
 }
 
 
 /************************* GET_FILESEARCH_DATA ************************/
 /************************* GET_FILESEARCH_DATA ************************/
 
 
 int get_filesearch_data(dataptr dz)
 int get_filesearch_data(dataptr dz)
-{   
-	int    exit_status;
-	int   srate = 0, total_words, n;
-	int    *inchans;
-	int   shsecsize = F_SECSIZE, *samplen;
-	double filedur;
-	double minsyncscan;
-	double *start, *end;
-	int    textfile_filetype = dz->infile->filetype;
-
-	if(dz->linecnt > SF_MAXFILES) {
-		sprintf(errstr,"Maximum number of sndfiles [%d] exceeded.\n",SF_MAXFILES);
-		return(USER_ERROR);
-	} else if(dz->linecnt <= 0) {
-		sprintf(errstr,"No data in sync file.\n");
-		return(USER_ERROR);
-	}
-	if((dz->parray[MSY_STARTSRCH] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store startsearch array.\n");
-		return(MEMORY_ERROR);
-	}
-	start = dz->parray[MSY_STARTSRCH];
-	if((dz->parray[MSY_ENDSRCH] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store endsearch array.\n");
-		return(MEMORY_ERROR);
-	}
-	end = dz->parray[MSY_ENDSRCH];
-	if((dz->lparray[MSY_SAMPSIZE] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"gINSUFFICIENT MEMORY to store sizes in samples.\n");
-		return(MEMORY_ERROR);
-	}
-	samplen = dz->lparray[MSY_SAMPSIZE];
-	if((dz->iparray[MSY_CHANS] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store channel info.\n");
-		return(MEMORY_ERROR);
-	}
-	inchans = dz->iparray[MSY_CHANS];
-	if((dz->lparray[MSY_PEAKSAMP] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
-		sprintf(errstr,"INSUFFICIENT MEMORY to store peak information.\n");
-		return(MEMORY_ERROR);
-	}
-	if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
-		return(exit_status);
-	total_words = 0;
-	for(n=0;n<dz->linecnt;n++) {
-		if((exit_status = open_file_and_retrieve_props(n,dz->wordstor[total_words],&srate,dz))<0)
-			return(exit_status);
-		samplen[n]	= dz->insams[0];
-		inchans[n]	= dz->infile->channels;
-//REVISION TW July, 2004
-//		filedur = (double)(samplen[n]/inchans[n])/(double)srate;
-		total_words += dz->wordcnt[n];
-	}
-
-	if(srate > SAMPLE_RATE_DIVIDE)  dz->iparam[MSY_SRFAC]=2;
-	else							dz->iparam[MSY_SRFAC]=1;
-
-	minsyncscan = (double)((shsecsize * dz->iparam[MSY_SRFAC])/MAX_WINFAC)/(double)srate;
-
-	total_words = 0;
-	for(n=0;n<dz->linecnt;n++) {
-		switch(dz->wordcnt[n]) {
-		case(3):
-			if(dz->infile->filetype==MIXFILE) {
-				sprintf(errstr,"Anomalous line length [%d] in mixfile\n",dz->wordcnt[n]);
-				return(PROGRAM_ERROR);
-			}
-			if(sscanf(dz->wordstor[total_words+1],"%lf",&(start[n]))!=1) {
-				sprintf(errstr,"Failed to read starttime: line %d: get_filesearch_data()\n",n+1);
-				return(PROGRAM_ERROR);
-			}
-			if(sscanf(dz->wordstor[total_words+2],"%lf",&(end[n]))!=1) {
-				sprintf(errstr,"Failed to read endtime: line %d: get_filesearch_data()\n",n+1);
-				return(PROGRAM_ERROR);
-			}
-			if((start[n] < 0.0) || (end[n] < 0.0) || (start[n] + minsyncscan >= end[n])) {
-				sprintf(errstr,"Impossible or incompatible searchtimes [%.5lf to %.5lf]: line %d.\n",
-				start[n],end[n],n+1);
-				return(USER_ERROR);
-			}
-//REVISION TW July, 2004
-			filedur = (double)(samplen[n]/inchans[n])/(double)srate;
-			if(start[n] >= filedur - minsyncscan) {
-				sprintf(errstr,"starttime on line %d is beyond effective file end.\n",n+1);
-				return(DATA_ERROR);
-			}
-			if(end[n] >= filedur)
-				end[n] = -1.0;	/* flags END_OF_SNDFILE */
-			break;
-		default:
-			start[n] = 0.0;
-			end[n]   = -1.0;	/* flags END_OF_SNDFILE */
-			break;
-		}
-		total_words += dz->wordcnt[n];
-	}
-	dz->infile->filetype = textfile_filetype;
-	return(FINISHED);
+{
+    int    exit_status;
+    int   srate = 0, total_words, n;
+    int    *inchans;
+    int   shsecsize = F_SECSIZE, *samplen;
+    double filedur;
+    double minsyncscan;
+    double *start, *end;
+    int    textfile_filetype = dz->infile->filetype;
+
+    if(dz->linecnt > SF_MAXFILES) {
+        sprintf(errstr,"Maximum number of sndfiles [%d] exceeded.\n",SF_MAXFILES);
+        return(USER_ERROR);
+    } else if(dz->linecnt <= 0) {
+        sprintf(errstr,"No data in sync file.\n");
+        return(USER_ERROR);
+    }
+    if((dz->parray[MSY_STARTSRCH] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store startsearch array.\n");
+        return(MEMORY_ERROR);
+    }
+    start = dz->parray[MSY_STARTSRCH];
+    if((dz->parray[MSY_ENDSRCH] = (double *)malloc(dz->linecnt * sizeof(double)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store endsearch array.\n");
+        return(MEMORY_ERROR);
+    }
+    end = dz->parray[MSY_ENDSRCH];
+    if((dz->lparray[MSY_SAMPSIZE] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"gINSUFFICIENT MEMORY to store sizes in samples.\n");
+        return(MEMORY_ERROR);
+    }
+    samplen = dz->lparray[MSY_SAMPSIZE];
+    if((dz->iparray[MSY_CHANS] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store channel info.\n");
+        return(MEMORY_ERROR);
+    }
+    inchans = dz->iparray[MSY_CHANS];
+    if((dz->lparray[MSY_PEAKSAMP] = (int *)malloc(dz->linecnt * sizeof(int)))==NULL) {
+        sprintf(errstr,"INSUFFICIENT MEMORY to store peak information.\n");
+        return(MEMORY_ERROR);
+    }
+    if((exit_status = establish_file_data_storage_for_mix((int)1,dz))<0)
+        return(exit_status);
+    total_words = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        if((exit_status = open_file_and_retrieve_props(n,dz->wordstor[total_words],&srate,dz))<0)
+            return(exit_status);
+        samplen[n]      = dz->insams[0];
+        inchans[n]      = dz->infile->channels;
+        //REVISION TW July, 2004
+        //              filedur = (double)(samplen[n]/inchans[n])/(double)srate;
+        total_words += dz->wordcnt[n];
+    }
+
+    if(srate > SAMPLE_RATE_DIVIDE)  dz->iparam[MSY_SRFAC]=2;
+    else                                                    dz->iparam[MSY_SRFAC]=1;
+
+    minsyncscan = (double)((shsecsize * dz->iparam[MSY_SRFAC])/MAX_WINFAC)/(double)srate;
+
+    total_words = 0;
+    for(n=0;n<dz->linecnt;n++) {
+        switch(dz->wordcnt[n]) {
+        case(3):
+            if(dz->infile->filetype==MIXFILE) {
+                sprintf(errstr,"Anomalous line length [%d] in mixfile\n",dz->wordcnt[n]);
+                return(PROGRAM_ERROR);
+            }
+            if(sscanf(dz->wordstor[total_words+1],"%lf",&(start[n]))!=1) {
+                sprintf(errstr,"Failed to read starttime: line %d: get_filesearch_data()\n",n+1);
+                return(PROGRAM_ERROR);
+            }
+            if(sscanf(dz->wordstor[total_words+2],"%lf",&(end[n]))!=1) {
+                sprintf(errstr,"Failed to read endtime: line %d: get_filesearch_data()\n",n+1);
+                return(PROGRAM_ERROR);
+            }
+            if((start[n] < 0.0) || (end[n] < 0.0) || (start[n] + minsyncscan >= end[n])) {
+                sprintf(errstr,"Impossible or incompatible searchtimes [%.5lf to %.5lf]: line %d.\n",
+                        start[n],end[n],n+1);
+                return(USER_ERROR);
+            }
+            //REVISION TW July, 2004
+            filedur = (double)(samplen[n]/inchans[n])/(double)srate;
+            if(start[n] >= filedur - minsyncscan) {
+                sprintf(errstr,"starttime on line %d is beyond effective file end.\n",n+1);
+                return(DATA_ERROR);
+            }
+            if(end[n] >= filedur)
+                end[n] = -1.0;  /* flags END_OF_SNDFILE */
+            break;
+        default:
+            start[n] = 0.0;
+            end[n]   = -1.0;        /* flags END_OF_SNDFILE */
+            break;
+        }
+        total_words += dz->wordcnt[n];
+    }
+    dz->infile->filetype = textfile_filetype;
+    return(FINISHED);
 }
 }
 
 
 /***************************** SYNCATT_PRESETS **************************/
 /***************************** SYNCATT_PRESETS **************************/
 
 
 int syncatt_presets(dataptr dz)
 int syncatt_presets(dataptr dz)
 {
 {
-	int exit_status;
-	if(!check_syncatt_window_factor(dz))
-		return(USER_ERROR);
-	if((exit_status= get_filesearch_data(dz))<0)
-		return(exit_status);
-	return(FINISHED);
+    int exit_status;
+    if(!check_syncatt_window_factor(dz))
+        return(USER_ERROR);
+    if((exit_status= get_filesearch_data(dz))<0)
+        return(exit_status);
+    return(FINISHED);
 }
 }
 
 
 /***************************** CHECK_SYNCATT_WINDOW_FACTOR **************************/
 /***************************** CHECK_SYNCATT_WINDOW_FACTOR **************************/
 
 
 int check_syncatt_window_factor(dataptr dz)
 int check_syncatt_window_factor(dataptr dz)
 {
 {
-	int valid_value = MIN_WINFAC;
-	while(valid_value <= MAX_WINFAC) {
-		if(dz->iparam[MSY_WFAC]==valid_value)
-			return(TRUE);
-		valid_value *= 2;
-	}
-	return(FALSE);
+    int valid_value = MIN_WINFAC;
+    while(valid_value <= MAX_WINFAC) {
+        if(dz->iparam[MSY_WFAC]==valid_value)
+            return(TRUE);
+        valid_value *= 2;
+    }
+    return(FALSE);
 }
 }

Some files were not shown because too many files changed in this diff