gobo.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /*
  2. * Copyright (c) 1983-2020 Trevor Wishart and Composers Desktop Project Ltd
  3. * http://www.trevorwishart.co.uk
  4. * http://www.composersdesktop.com
  5. *
  6. This file is part of the CDP System.
  7. The CDP System is free software; you can redistribute it
  8. and/or modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11. The CDP System is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License aint with the CDP System; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18. 02111-1307 USA
  19. *
  20. */
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <osbind.h>
  25. #include <processno.h>
  26. /*
  27. #include <minmax.h>
  28. */ /*RWD not allowed: not portable. incloude sfsys.h instead */
  29. #include <sfsys.h>
  30. #include "filetype.h"
  31. #include <standalone.h>
  32. /******* masking GOBOs for the list of programs: each contains 'maskcnt' bitflags, each of 32 bits ********/
  33. #define NUMBER_OF_GOBOS (42)
  34. #define ORIG_MASK_ARRAY_ELEMENTS_CNT (17) /* No of masks on original release + 2 for experimental progs */
  35. // ~~ ***** ADDING A NEW BLOCK OF 32 PROGRAMS : Need to INCREMENT "ORIG_MASK_ARRAY_ELEMENTS_CNT" *** ~~
  36. // ~~ ***** that would be AFTER PROCESS 544 as at June 17th :2020 **** ~~
  37. // ~~ ALSO FIX SPECIAL GOBO MASKS IN
  38. // ~~ _bulk.tcl:
  39. // ~~ _progmask.tcl:
  40. // ~~ _standalone.tcl:
  41. #define INT_SIZE (32) /* Flags assumed to be in 32-bit ints : BUT DON'T CHANGE THIS EVEN IF ints ARE intER!! */
  42. #define CHARBITSIZE (8) /* bits in a char */
  43. int gobo1[] = {-1,-1,-1,-1,-1,-1,-16777217,-1,2147483647,-1,-1,-16778241,-1,-939532289,-164097,-19955569,15}; /* set to zero any process that changes srate */
  44. int gobo2[] = {0,0,0,1,2097152,2097152,0,557873152,0,1048592,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* set to 1 if process works with zero files */
  45. int gobo3[] = {-1549,-402681857,-16779252,-1048580,-27787265,-14683905,-1310721,-558070023,1609791102,-340820177,-4444827,2063596061,-515137604,-1071658209,-1075876101,-20479857,14}; /* works with 1 files 1,1+ */
  46. int gobo4[] = {1548,2013294592,1073743859,-133169150,25690623,4198144,169083268,196871,537692545,340394432,8638618,1412432352,112222288,1048749,134369284,268959744,1}; /* works with 2 files 2,1+,2+ */
  47. int gobo5[] = {8,0,1073742208,-134217728,511,4195328,168821124,131075,1,273318336,8573064,1412431872,471883792,1052685,134365188,268435456,1}; /* works with 3 files 3,1+,2+ */
  48. int gobo6[] = {0,0,1073742208,-134217728,511,4195328,168821124,131075,1,273285568,8573064,1412431872,471883792,1052685,134365188,268435456,1}; /* works with any number of files (not 0) 1+,2+ */
  49. int gobo7[] = {-1,-536739841,134741995,1,2097152,2097152,-501218304,29391136,813695105,34750480,4194816,-2147479046,8654547,132302272,1084228099,2089680900,0}; /* File1 = ANAL: else 0 */
  50. int gobo8[] = {0,536739840,16252944,1,2097152,2097152,-501219328,21002528,258,3390992,6291968,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = PICH (binary): else 0 */
  51. int gobo9[] = {0,402653184,2097152,1,2097152,2097152,-501219328,21002528,0,1179664,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = TRNS (binary): else 0 */
  52. int gobo10[] = {0,0,4,1,2097152,2097152,-501219328,21002528,64,1179664,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = FMNT : else 0 */
  53. int gobo11[] = {0,0,-167772160,-1,-201326593,-10481917,-67113985,1564508159,1333788220,-35782152,-2154537,-16784889,-549457629,-939712897,-8422148,-2109636469,15}; /* File1 = SND : else 0 */
  54. int gobo12[] = {0,0,0,1,69206016,2097164,-501219328,21002528,0,1179664,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = ENV (binary) : else 0 */
  55. int gobo13[] = {0,0,0,1,2097152,2097152,606076928,4225024,0,1048592,4211200,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = TextFile (NOT exclusively numbers): else 0 */
  56. int gobo14[] = {0,402653184,0,1,2097152,2097152,572526592,21002240,0,1048599,4203008,-2147483646,262159,132121664,1075838976,0,0}; /* File1 = pitch or transpos textfile: else 0 */
  57. int gobo15[] = {0,0,0,1,2097152,2097248,572526592,21002240,0,1048592,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = dB-envelope textfile: else 0 */
  58. int gobo16[] = {0,0,0,1,136314880,2097296,572526592,21002240,0,1048599,4203008,-2147483646,262159,132121664,1075838976,0,0}; /* File1 = normalised-envelope textfile: else 0 */
  59. int gobo17[] = {0,0,0,1,2097152,2097152,572526592,21002240,0,1048599,4203008,-2147481598,262159,132121664,1075838976,0,0}; /* File1 = unranged brktable textfile: else 0 */
  60. int gobo18[] = {0,0,0,1,2097152,2359296,639635456,16807936,0,1048592,4194816,-2147483646,541327363,132121664,1075838976,0,0}; /* File1 = list of sndfiles in a textfile: else 0 */
  61. int gobo19[] = {0,0,0,1,2097152,2621440,35655680,21002240,0,1048592,4194816,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = sndfile synchronisation list: else 0 */
  62. int gobo20[] = {0,0,0,1,2097152,4190208,572526592,-2126481408,0,1048592,4227624,-2147483646,262147,132121664,1075838976,0,0}; /* File1 = mixfile: else 0 */
  63. int gobo21[] = {0,0,0,1,2097152,2097152,572526592,58718208,0,1048599,4203008,-2147483646,262159,132121664,1075838976,0,0}; /* File1 = textfile of list-of-numbers: else 0 */
  64. int gobo22[] = {-1,-1,-16777217,-1,-1,-12582913,-1,-603979777,2147483647,-1,-1,-16778241,-1,-939532289,-33025,-19955569,15}; /* Always 1 / non-functional */
  65. int gobo23[] = {-1,-1,-16777217,-1,-1,-14675969,-1,-603979777,2147483647,-1,-1,-16778241,-541065217,-939532289,-33025,-19955569,15}; /* If file1=sndlist/synclist, if these must be same SR, set to 0*/
  66. int gobo24[] = {-1,-1,-16777217,-1,-1,-8388609,-1,-641695745,2147483647,-1,-1,-16778241,-1,-939532289,-33025,-19955569,15}; /* Always 1 / non-functional */
  67. int gobo25[] = {-1,-1,-1090519041,-1,-1,-8388609,-268435457,-536871489,2147483647,-1,-321,-16778241,-1,-939532289,-39169,-20021105,15}; /* Reject progs not accepting mono sndsys files by setting to 0*/
  68. int gobo26[] = {-1,-536739841,1544028139,-4194297,-201326593,-8389646,-35329,1610612735,914362497,-1747041840,785784791,-50392065,-1064845613,-941432864,1593318019,-53542907,7}; /* Reject progs not accepting stereo sndsys files by setting to 0: pitch, formants, transpos, and envbin get 0 */
  69. int gobo27[] = {-1,-536739841,470286315,130023431,-201327104,-14677006,-402688569,1610612223,914362497,-1814674992,785784343,-52489734,-1064845613,-941432864,1593311875,-53608443,7};/* If process won't run with >2chas,sets to 0,all ANAL progs=1: sndprogs limited to stereo max get 0, pitch,formants,transpos,& envbin get 0 */
  70. int gobo28[] = {-1541,-2013265921,-1090519058,-1048579,-25690113,-12586753,-135528837,-637730824,2146662015,-340296129,-8638619,-1429210113,-506486785,-940585006,-134402309,-19955569,14}; /* >1 file: to reject all lastfiles except =ANAL set to 1*/
  71. int gobo29[] = {-1549,-2013294593,-1090521059,-1048579,-25690113,-12586753,-135528837,-637730824,1609791486,-340296129,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: to reject all lastfiles except =FMNT set to 1*/
  72. int gobo30[] = {-1549,-2013294593,-16779252,-1,-1,-8388609,-1,-637730817,1610612350,-67141633,-1,-16778721,-8388689,-939532417,-33025,-288915313,15}; /* >1 file: to reject all lastfiles except =SND set to 1*/
  73. int gobo31[] = {-9,-28673,-1090521076,-1048579,-25690113,-12586753,-135528837,-637730824,1609791102,-340296129,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: to reject all lastfiles except =PCH or TRNSP binary set to 1*/
  74. int gobo32[] = {-1549,-1610641409,-1090521076,-1048579,-524289,-12586753,-135528837,-603980040,1609791102,-273318337,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: to reject all lastfiles except =ENV(or dBENV) BRK set to 1*/
  75. int gobo33[] = {-1549,-1610641409,-1090521076,-1048579,-25690113,-12586753,-135528837,-637731080,1609791102,-340427201,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* if lastfile = textfile: if you want to reject all lastfiles except number lists, set to 0 */
  76. int gobo34[] = {-9,-28673,-1090521059,133169151,-524800,-8391937,-135266693,-637730824,2147483646,-273154497,-8523905,-1429210113,-471883793,-940584961,-134398213,-288391025,14}; /* >1 file: if all files must be same type: set to 0 */
  77. int gobo35[] = {-1549,-1610641409,-1090521076,133169149,-512,-12586753,-135528837,-637730819,1609791102,-273154241,-8589459,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: if all files must be same srate: set to 0 */
  78. int gobo36[] = {-1549,-1610641409,-1090521076,133169151,-512,-8392193,-135528577,-637730819,1609791102,-272629953,-8589331,-1362101729,-514875473,-940585102,-134402309,-288915313,14}; /* >1 file: if all files must be same chancnt: set to 0 */
  79. int gobo37[] = {-1549,-1610641409,-16779252,-1048577,-1,-8391937,-1,-637730824,1610612350,-1,-1,-16778721,-8388689,-939532417,-33025,-20479857,15}; /* >1 file: if all files must be same other props: set to 0 : but 1 for all sndfile only processes */
  80. int gobo38[] = {-1,-134217729,-16777217,-1,-1,-8388609,-1,-603979777,2147483647,-1,-1,-16778241,-1,-939532289,-33025,-19955569,15}; /* >1 file: if infiles are P and T, and output is binary, and hence 1 input must be binary: set to 0 */
  81. int gobo39[] = {-1549,-2013294593,-1090521076,-3,-524289,-12586753,-135528837,-637731080,1609791102,-340394433,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: to reject all lastfiles except =ENV binary set to 1*/
  82. int gobo40[] = {-1549,-1610641409,-1090521076,-1048579,-524289,-12586753,-135528837,-603980040,1609791102,-273318337,-8638619,-1429210593,-514875473,-940585134,-134402309,-288915313,14}; /* >1 file: if it can't use textfile as lastfile, set to 0 */
  83. int gobo41[] = { -1,-1,-1,-1,-8388609,-1,-1,-1,2147483647,-67108865,-1,-16778241,-1,-939532289,-33025,-19955569,15}; /* always set to 1 for NEW progs */
  84. int gobo42[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* always set to 1 for NEW progs */
  85. int gobo_any[] = {0,0,0,0,0,0,33554432,0,0,0,0,0,0,0,0,0,0}; /* processes which work with absolutely ANY files (i.e. including non-CDP valid files): set to 1, else set to 0 */
  86. int gobozero[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* set all gobos to 0 */
  87. void usage(void);
  88. void gobo_EQUALS(int** gobo_1,int gobo_2[]);
  89. void gobo_AND(int** gobo_1,int* gobo_2);
  90. void gobo_OR(int** gobo_1,int* gobo_2);
  91. void gobo_ZEROED(int** gobo_1);
  92. /***** TESTING ONLY ******/
  93. int show(char *str,int *gobo_out,int progno,int valid_multifile);
  94. #define FALSE (0)
  95. #define TRUE (1)
  96. #define ALL_INFILES_OF_SAME_TYPE (16)
  97. #define ALL_INFILES_OF_SAME_SRATE (8)
  98. #define ALL_INFILES_OF_SAME_CHANCNT (4)
  99. #define ALL_INFILES_OF_SAME_PROPS (2)
  100. #define AT_LEAST_ONE_PFT_INFILE (1)
  101. /***** DATA COMING FROM INPUT FILES *****
  102. [1] Count of input files
  103. [2] Filetype of 1st infile
  104. [3] Filetype of last infile
  105. [4] Cumulative filetypes (those types which all files share)
  106. [5] Bitflag re file compatibility etc. (16+8+4+2+1)
  107. # 16 = all infiles of same type
  108. # 8 = all infiles of same srate
  109. # 4 = all infiles of same channel count
  110. # 2 = all infiles have all other properties compatible
  111. # 1 = At least 1 of infiles is a binary PFT file
  112. [6] Number of channels (of all files, if all have same channels: otherwise, of last file)
  113. ****/
  114. int process_for_single_file = 0;
  115. int maskcnt;
  116. const char* cdp_version = "8.0.0";
  117. /*******************************************************************/
  118. int main(int argc, char *argv[])
  119. {
  120. int filecnt, n, m;
  121. int firstfile_type=0,lastfile_type=0,compatibility=0,chancnt=0, mask;
  122. int ismachine_create = 0, is_fixed_srate = 0;
  123. unsigned int start = hz1000();
  124. int pbrk = FALSE;
  125. int tbrk = FALSE;
  126. int tfile = FALSE;
  127. int mixlist = FALSE;
  128. int pfile2 = FALSE;
  129. int pbrk2 = FALSE;
  130. int tbrk2 = FALSE;
  131. int nlist2 = TRUE;
  132. int valid_multifile = TRUE;
  133. int *gobo_out, *gobo_accumulate=NULL;
  134. char *temp;
  135. int progno = -1;
  136. int cmdline_testing_mode = 0;
  137. if(argc==2 && (strcmp(argv[1],"--version") == 0)) {
  138. fprintf(stdout,"%s\n",cdp_version);
  139. fflush(stdout);
  140. return 0;
  141. }
  142. maskcnt = min(((MAX_PROCESS_NO - 1)/32) + 1,ORIG_MASK_ARRAY_ELEMENTS_CNT);
  143. if(argc == 1) {
  144. fprintf(stdout,"TO TEST THE GOBO SETTING FOR A NEW PROGRAM\n\n");
  145. fprintf(stdout,"1) In the soundloom code, MAIN, set gobo_testing to 1\n");
  146. fprintf(stdout,"2) restart the SOUND LOOM, choose zero or more files, & proceed to process.\n");
  147. fprintf(stdout,"3) When the gobo cmdline is displayed, note it down.\n");
  148. fprintf(stdout,"4) Now run gobo in command.tos, using the same cmdline PLUS\n");
  149. fprintf(stdout," THE PROCESS NUMBER, placed at the end of the cmdline.\n");
  150. fprintf(stdout," (The process number can be found in the file 'processno.h')\n\n");
  151. fprintf(stdout," The GOBO program will report at what stage it decides that\n");
  152. fprintf(stdout," the process will not run with the files entered.\n\n");
  153. fprintf(stdout," If you are developing a new application, and the process SHOULD run\n");
  154. fprintf(stdout," with the entered files, you need to correct the program's gobo settings.\n");
  155. return(0);
  156. }
  157. if(argc==5 || argc == 9) {
  158. if(sscanf(argv[argc-1],"%d",&progno)!=1) {
  159. fprintf(stderr,"Invalid program number given.\n");
  160. while (!(hz1000() - start))
  161. ;
  162. return(-1);
  163. } else if (progno < 1 || progno > MAX_PROCESS_NO) {
  164. fprintf(stderr,"Program number %d does not exist.\n",progno);
  165. while (!(hz1000() - start))
  166. ;
  167. return(-1);
  168. }
  169. cmdline_testing_mode = 1;
  170. argc--;
  171. }
  172. if(argc < 4) {
  173. fprintf(stdout,"ERROR: Incorrect call to gobo program: not enough args\n");
  174. while (!(hz1000() - start))
  175. ;
  176. return(-1);
  177. }
  178. if(sscanf(argv[1],"%d",&filecnt)!=1) {
  179. fprintf(stdout,"ERROR: Cannot read filecnt argument to gobo program.\n");
  180. while (!(hz1000() - start))
  181. ;
  182. return(-1);
  183. }
  184. if(sscanf(argv[2],"%d",&ismachine_create)!=1) {
  185. fprintf(stdout,"ERROR: Cannot read machinecreate argument to gobo program.\n");
  186. while (!(hz1000() - start))
  187. ;
  188. return(-1);
  189. }
  190. if(sscanf(argv[3],"%d",&is_fixed_srate)!=1) {
  191. fprintf(stdout,"ERROR: Cannot read is_fixed_srate argument to gobo program.\n");
  192. while (!(hz1000() - start))
  193. ;
  194. return(-1);
  195. }
  196. if(filecnt > 0) { /* if process has files, read the data on filetypes etc */
  197. if(argc!=8) {
  198. fprintf(stdout,"ERROR: Incorrect call to gobo program: too many args\n");
  199. while (!(hz1000() - start))
  200. ;
  201. return(-1);
  202. }
  203. if(sscanf(argv[4],"%d",&firstfile_type)!=1) {
  204. fprintf(stdout,"ERROR: Cannot read firstfile_type argument to [3] gobo program.\n");
  205. while (!(hz1000() - start))
  206. ;
  207. return(-1);
  208. }
  209. if(sscanf(argv[5],"%d",&lastfile_type)!=1) {
  210. fprintf(stdout,"ERROR: Cannot read lastfile_type argument to [4] gobo program.\n");
  211. while (!(hz1000() - start))
  212. ;
  213. return(-1);
  214. }
  215. if(sscanf(argv[6],"%d",&compatibility)!=1) {
  216. fprintf(stdout,"ERROR: Cannot read compatibility argument [5] to gobo program.\n");
  217. while (!(hz1000() - start))
  218. ;
  219. return(-1);
  220. }
  221. if(sscanf(argv[7],"%d",&chancnt)!=1) {
  222. fprintf(stdout,"ERROR: Cannot read channel count argument [6] to gobo program.\n");
  223. while (!(hz1000() - start))
  224. ;
  225. return(-1);
  226. }
  227. }
  228. if((gobo_out = malloc(maskcnt * sizeof(int)))==NULL) {
  229. fprintf(stdout,"ERROR: Can't allocate memory space 1 for gobos.\n");
  230. while (!(hz1000() - start))
  231. ;
  232. return(-1);
  233. }
  234. if(filecnt > 0) {
  235. if((gobo_accumulate = malloc(maskcnt * sizeof(int)))==NULL) {
  236. fprintf(stdout,"ERROR: Can't allocate memory space 2 for gobos.\n");
  237. while (!(hz1000() - start))
  238. ;
  239. return(-1);
  240. }
  241. for(n=0;n<maskcnt;n++)
  242. gobo_accumulate[n] = 0;
  243. }
  244. /* Initialise the process gobos for process or machine situations */
  245. if(filecnt == 0) {
  246. if(ismachine_create)
  247. gobo_EQUALS(&gobo_out,gobozero); /* initialise gobo to accept all machine-compatible 0 file procs */
  248. else
  249. gobo_EQUALS(&gobo_out,gobo2); /* initialise gobo to accept all progs requiring 0 files */
  250. } else {
  251. /* If there are input files, adjust processes-gobo according to file props */
  252. gobo_ZEROED(&gobo_out); /* initialise gobo to accept nothing */
  253. switch(filecnt) { /* accept programs on basis of input filecnt */
  254. case(1): valid_multifile = FALSE;
  255. process_for_single_file = 1;
  256. gobo_OR(&gobo_out,gobo3); /* all progs requiring 1 file, or 1-or-more files */ break;
  257. case(2): gobo_OR(&gobo_out,gobo4); /* all progs requiring 2 files,1-or-more files,2-or-more files */ break;
  258. case(3): gobo_OR(&gobo_out,gobo5); /* all progs requiring 3 files,1-or-more files,2-or-more files */ break;
  259. default: gobo_OR(&gobo_out,gobo6); /* all progs requiring 1-or-more files, 2-or-more files */ break;
  260. }
  261. if(cmdline_testing_mode && !show("AFTER FILECNT TEST (gobo6)",gobo_out,progno,valid_multifile))
  262. return(0);
  263. if(is_fixed_srate)
  264. gobo_AND(&gobo_out,gobo1); /* if interface uses fixed srate, disallow srate-changing progs */
  265. if(cmdline_testing_mode && !show("AFTER TEST FOR SYSTEM AT FIXED SRATE (gobo1)",gobo_out,progno,valid_multifile))
  266. return(0);
  267. switch(firstfile_type) {
  268. case(ANALFILE): gobo_AND(&gobo_out,gobo7); /* Accept only progs having ANALFILE as first file */ break;
  269. case(PITCHFILE): gobo_AND(&gobo_out,gobo8); /* Accept only progs having PITCHFILE as first file */ break;
  270. case(TRANSPOSFILE): tfile = TRUE;
  271. gobo_AND(&gobo_out,gobo9); /* Accept only progs having TRANSPOSFILE as first file */ break;
  272. case(FORMANTFILE): gobo_AND(&gobo_out,gobo10); /* Accept only progs having FORMANTFILE as first file */ break;
  273. case(SNDFILE): gobo_AND(&gobo_out,gobo11); /* Accept only progs having SNDFILE as first file */ break;
  274. case(ENVFILE): gobo_AND(&gobo_out,gobo12); /* Accept only progs having ENVELOPE BINFILE as 1st file */ break;
  275. case(LINELIST_OR_WORDLIST):
  276. gobo_AND(&gobo_out,gobo13); /* Accept only progs of textlines(not just nos.) as file1*/ break;
  277. case(WORDLIST): gobo_AND(&gobo_out,gobo13); /* Accept only prgs havng unspecific words */
  278. /*(& not only numbers) as 1st file */ break;
  279. default: /* DEAL WITH ALL OTHER TEXTFILE TYPES */
  280. if(firstfile_type & IS_A_PITCH_BRKFILE) pbrk = TRUE;
  281. if(firstfile_type & IS_A_TRANSPOS_BRKFILE) tbrk = TRUE;
  282. if(pbrk || tbrk)
  283. gobo_OR(&gobo_accumulate,gobo14); /* Accept progs having pitch or transpos textfile as first file */
  284. if(firstfile_type & IS_A_DB_BRKFILE)
  285. gobo_OR(&gobo_accumulate,gobo15); /* Accept progs having dB-envelope textfile as first file */
  286. if(firstfile_type & IS_A_NORMD_BRKFILE)
  287. gobo_OR(&gobo_accumulate,gobo16); /* Accept progs having normalised-envelope textfile as first file */
  288. if(firstfile_type & IS_AN_UNRANGED_BRKFILE)
  289. gobo_OR(&gobo_accumulate,gobo17); /* Accept progs having unranged brktable textfile as first file */
  290. if(firstfile_type & IS_A_SNDLIST)
  291. gobo_OR(&gobo_accumulate,gobo18); /* Accept progs having list of sndfiles in a textfile as first file */
  292. if(firstfile_type & IS_A_SYNCLIST)
  293. gobo_OR(&gobo_accumulate,gobo19); /* Accept progs having sndfile synchronisation list as first file */
  294. if((firstfile_type & IS_A_MIXFILE) && (firstfile_type != WORDLIST)) {
  295. mixlist = TRUE;
  296. gobo_OR(&gobo_accumulate,gobo20); /* Accept progs having mixfile textfile as first file */
  297. }
  298. if(firstfile_type & IS_A_NUMLIST)
  299. gobo_OR(&gobo_accumulate,gobo21); /* Accept progs having list-of-numbers textfile as first file */
  300. gobo_AND(&gobo_out,gobo_accumulate); /* Accept all the accumulated progs (only) */
  301. if((firstfile_type & IS_A_SNDLIST_FIXEDSR) != IS_A_SNDLIST_FIXEDSR) {
  302. if(!mixlist)
  303. gobo_AND(&gobo_out,gobo23);
  304. }
  305. }
  306. if(cmdline_testing_mode && !show("AFTER FILETYPE TESTS",gobo_out,progno,valid_multifile))
  307. return(0);
  308. switch(chancnt) {
  309. case(0):
  310. break; /* Ignore files with 0 chans (textfiles) */
  311. case(1):
  312. gobo_AND(&gobo_out,gobo25); /* Reject progs not accepting mono files */
  313. break;
  314. case(2):
  315. gobo_AND(&gobo_out,gobo26); /* Reject progs not accepting stereo files */
  316. break;
  317. default:
  318. gobo_AND(&gobo_out,gobo27); /* Reject progs taking ONLY mono or stereo files */
  319. break;
  320. }
  321. if(cmdline_testing_mode && !show("AFTER CHANNEL CNT TEST (gobo27)",gobo_out,progno,valid_multifile))
  322. return(0);
  323. if(valid_multifile) { /* i.e. More than 1 input file */
  324. if(cmdline_testing_mode && !show("AFTER VALID MULTIFILE TEST",gobo_out,progno,valid_multifile))
  325. return(0);
  326. switch(lastfile_type) {
  327. case(ANALFILE): gobo_AND(&gobo_out,gobo28); /* Accept only progs taking analfile as last file */ break;
  328. case(FORMANTFILE): gobo_AND(&gobo_out,gobo29); /* Accept only progs taking fmntfile as last file */ break;
  329. case(SNDFILE): gobo_AND(&gobo_out,gobo30); /* Accept only progs taking sndfile as last file */ break;
  330. case(PITCHFILE): pfile2 = TRUE;
  331. /* fall thro */
  332. case(TRANSPOSFILE): gobo_AND(&gobo_out,gobo31); /* Accept only progs taking pitch */
  333. /* or transpos binfile as last file */
  334. if(cmdline_testing_mode && !show("2nd FILE IS P or T BINARY",gobo_out,progno,valid_multifile))
  335. return(0);
  336. break;
  337. case(ENVFILE): gobo_AND(&gobo_out,gobo39);/* progs taking only env-binfiles as last file */ break;
  338. default: /* DEAL WITH ALL TEXTFILE TYPES */
  339. if(!(lastfile_type & IS_A_TEXTFILE)) {
  340. valid_multifile = FALSE;
  341. if(cmdline_testing_mode && !show("2nd FILE IS NOT A TEXTFILE",gobo_out,progno,valid_multifile))
  342. return(0);
  343. gobo_EQUALS(&gobo_out,gobo_any); /* i.e. Nothing else works, except HOUSE-BUNDLE options */
  344. } else {
  345. gobo_AND(&gobo_out,gobo40); /* Drop all files that DON'T use textfile as last file */
  346. if(cmdline_testing_mode && !show("2nd FILE IS A TEXTFILE",gobo_out,progno,valid_multifile))
  347. return(0);
  348. if(lastfile_type & IS_A_PITCH_BRKFILE) pbrk2 = TRUE;
  349. if(lastfile_type & IS_A_TRANSPOS_BRKFILE) tbrk2 = TRUE;
  350. if(!((lastfile_type & IS_A_NORMD_BRKFILE) || (lastfile_type & IS_A_DB_BRKFILE)))
  351. gobo_AND(&gobo_out,gobo32); /* Accept only progs taking envelope type brkfiles */
  352. if(cmdline_testing_mode && !show("AFTER NORMD-BRKFILE TEST (gobo32)",gobo_out,progno,valid_multifile))
  353. return(0);
  354. if(!(lastfile_type & IS_A_DB_BRKFILE)
  355. && !(lastfile_type & IS_A_NORMD_BRKFILE)
  356. && !(lastfile_type & IS_A_TRANSPOS_BRKFILE)
  357. && !(lastfile_type & IS_A_POSITIVE_BRKFILE))
  358. gobo_AND(&gobo_out,gobo41); /* env-impose exception */
  359. if(cmdline_testing_mode && !show("UNRANGED BRKFILE TEST",gobo_out,progno,valid_multifile))
  360. return(0);
  361. if((lastfile_type & IS_A_NUMBER_LINELIST) != IS_A_NUMBER_LINELIST) {
  362. nlist2 = FALSE;
  363. gobo_AND(&gobo_out,gobo33); /* Reject progs not taking list of numbers as lastfile */
  364. }
  365. if(cmdline_testing_mode && !show("NUMBER LIST TEST (gobo33)",gobo_out,progno,valid_multifile))
  366. return(0);
  367. if(!(pbrk2 || tbrk2 || nlist2)) { /* Nothing else works, except 0-FILE options */
  368. valid_multifile = FALSE;
  369. gobo_EQUALS(&gobo_out,gobo_any);
  370. }
  371. if(cmdline_testing_mode && !show("ALL OTHER TEXTFILES TEST",gobo_out,progno,valid_multifile))
  372. return(0);
  373. }
  374. }
  375. if(cmdline_testing_mode && !show("LAST FILETYPE",gobo_out,progno,valid_multifile))
  376. return(0);
  377. if(valid_multifile) {
  378. if((tfile||tbrk) && !pbrk && (pfile2||pbrk2) && !tbrk2) {
  379. valid_multifile = FALSE; /* Can't have Tfile followed by Pfile */
  380. gobo_EQUALS(&gobo_out,gobo_any);
  381. } else {
  382. if(!(compatibility & ALL_INFILES_OF_SAME_TYPE)) gobo_AND(&gobo_out,gobo34);
  383. if(!(compatibility & ALL_INFILES_OF_SAME_SRATE)) gobo_AND(&gobo_out,gobo35);
  384. if(!(compatibility & ALL_INFILES_OF_SAME_CHANCNT)) gobo_AND(&gobo_out,gobo36);
  385. if(!(compatibility & ALL_INFILES_OF_SAME_PROPS)) gobo_AND(&gobo_out,gobo37);
  386. if(!(compatibility & AT_LEAST_ONE_PFT_INFILE)) gobo_AND(&gobo_out,gobo38);
  387. }
  388. }
  389. if(cmdline_testing_mode && !show("AFTER COMPATIBILITY TEST",gobo_out,progno,valid_multifile))
  390. return(0);
  391. }
  392. /* KLUJ for NEW MUTICHANNEL MIXFILES */
  393. if(firstfile_type == MIX_MULTI) {
  394. for(n=0;n<maskcnt;n++)
  395. gobo_out[n] = 0;
  396. gobo_out[7] = /* -2147483648 */ 0x80000000; /* RWD: bypass gcc warning about signedness. NB: assumes 32bit int! */
  397. }
  398. }
  399. if(cmdline_testing_mode && !show("AFTER ALL TESTS",gobo_out,progno,valid_multifile))
  400. return(0);
  401. if((temp = malloc((maskcnt * ((sizeof(int) * CHARBITSIZE)+1)) + 2))==NULL) {
  402. fprintf(stdout,"ERROR: Can't allocate memory space 3 for gobos.\n");
  403. while (!(hz1000() - start))
  404. ;
  405. return(-1);
  406. }
  407. temp[0] = '\0';
  408. for(n=0;n<maskcnt;n++) {
  409. mask = 1;
  410. for(m=0;m<INT_SIZE;m++) {
  411. if(gobo_out[n] & mask)
  412. strcat(temp,"1");
  413. else
  414. strcat(temp,"0");
  415. mask <<= 1;
  416. }
  417. }
  418. strcat(temp,"\n");
  419. fprintf(stdout,"%s\n",temp);
  420. while (!(hz1000() - start))
  421. ;
  422. return(0);
  423. }
  424. /********************************* gobo_EQUALS *********************************/
  425. void gobo_EQUALS(int** gobo_1,int gobo_2[])
  426. {
  427. int n;
  428. for(n=0;n<maskcnt;n++)
  429. (*gobo_1)[n] = gobo_2[n];
  430. }
  431. /********************************* gobo_ZEROED *********************************/
  432. void gobo_ZEROED(int** gobo_1)
  433. {
  434. int n;
  435. for(n=0;n<maskcnt;n++)
  436. (*gobo_1)[n] = 0;
  437. }
  438. /********************************* gobo_AND *********************************/
  439. void gobo_AND(int** gobo_1,int* gobo_2)
  440. {
  441. int n;
  442. for(n=0;n<maskcnt;n++)
  443. (*gobo_1)[n] &= gobo_2[n];
  444. }
  445. /********************************* gobo_OR **********************************/
  446. void gobo_OR(int** gobo_1,int* gobo_2)
  447. {
  448. int n;
  449. for(n=0;n<maskcnt;n++)
  450. (*gobo_1)[n] |= gobo_2[n];
  451. }
  452. int show(char *str,int *gobo_out,int progno,int valid_multifile) {
  453. int mask = 1;
  454. int gobono, itemno, n = 0;
  455. progno--;
  456. gobono = progno/32;
  457. itemno = progno%32;
  458. if(itemno>0) {
  459. for(n=0;n<itemno;n++) {
  460. mask <<= 1;
  461. }
  462. }
  463. if(gobo_out[gobono] & mask) {
  464. if(process_for_single_file == 1)
  465. fprintf(stdout,"%s: process OK\n",str);
  466. else if(valid_multifile)
  467. fprintf(stdout,"%s: process OK: with these files\n",str);
  468. else
  469. fprintf(stdout,"%s: process OK: but NOT with these files\n",str);
  470. return(1);
  471. } else {
  472. fprintf(stdout,"%s: process NOT OK\n",str);
  473. return(0);
  474. }
  475. }