ap_stretch.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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 along 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 <structures.h>
  24. #include <cdpmain.h>
  25. #include <tkglobals.h>
  26. #include <pnames.h>
  27. #include <stretch.h>
  28. #include <processno.h>
  29. #include <modeno.h>
  30. #include <globcon.h>
  31. #include <logic.h>
  32. #include <filetype.h>
  33. #include <mixxcon.h>
  34. #include <speccon.h>
  35. #include <flags.h>
  36. #include <arrays.h>
  37. #include <formants.h>
  38. #include <sfsys.h>
  39. #include <osbind.h>
  40. #include <string.h>
  41. #include <math.h>
  42. #include <srates.h>
  43. /********************************************************************************************/
  44. /********************************** FORMERLY IN buffers.c ***********************************/
  45. /********************************************************************************************/
  46. static int allocate_tstretch_buffer(dataptr dz);
  47. /********************************************************************************************/
  48. /********************************** FORMERLY IN pconsistency.c ******************************/
  49. /********************************************************************************************/
  50. static int check_viability_and_compatibility_of_stretch_params(dataptr dz);
  51. static int check_for_enough_tstretch_brkpnt_vals(dataptr dz);
  52. /********************************************************************************************/
  53. /********************************** FORMERLY IN preprocess.c ********************************/
  54. /********************************************************************************************/
  55. #define POSMIN (200) /* Minimum size for positions array in spec tstretch */
  56. static int set_internal_stretch_params(dataptr dz);
  57. static int setup_internal_params_for_tstretch(dataptr dz);
  58. /***************************************************************************************/
  59. /****************************** FORMERLY IN aplinit.c **********************************/
  60. /***************************************************************************************/
  61. /***************************** ESTABLISH_BUFPTRS_AND_EXTRA_BUFFERS **************************/
  62. int establish_bufptrs_and_extra_buffers(dataptr dz)
  63. {
  64. int exit_status;
  65. int is_spec = FALSE;
  66. dz->extra_bufcnt = -1; /* ENSURE EVERY CASE HAS A PAIR OF ENTRIES !! */
  67. dz->bptrcnt = 0;
  68. dz->bufcnt = 0;
  69. switch(dz->process) {
  70. case(STRETCH): dz->extra_bufcnt = 0; dz->bptrcnt = 1; is_spec = TRUE; break;
  71. case(TSTRETCH): dz->extra_bufcnt = 0; dz->bptrcnt = 6; is_spec = TRUE; break;
  72. default:
  73. sprintf(errstr,"Unknown program type [%d] in establish_bufptrs_and_extra_buffers()\n",dz->process);
  74. return(PROGRAM_ERROR);
  75. }
  76. if(dz->extra_bufcnt < 0) {
  77. sprintf(errstr,"bufcnts have not been set: establish_bufptrs_and_extra_buffers()\n");
  78. return(PROGRAM_ERROR);
  79. }
  80. if(is_spec)
  81. return establish_spec_bufptrs_and_extra_buffers(dz);
  82. else if((dz->process==HOUSE_SPEC && dz->mode==HOUSE_CONVERT) || dz->process==INFO_DIFF) {
  83. if((exit_status = establish_spec_bufptrs_and_extra_buffers(dz))<0)
  84. return(exit_status);
  85. }
  86. return establish_groucho_bufptrs_and_extra_buffers(dz);
  87. }
  88. /***************************** SETUP_INTERNAL_ARRAYS_AND_ARRAY_POINTERS **************************/
  89. int setup_internal_arrays_and_array_pointers(dataptr dz)
  90. {
  91. int n;
  92. dz->ptr_cnt = -1; /* base constructor...process */
  93. dz->array_cnt = -1;
  94. dz->iarray_cnt = -1;
  95. dz->larray_cnt = -1;
  96. switch(dz->process) {
  97. case(STRETCH): dz->array_cnt = 0; dz->iarray_cnt = 0; dz->larray_cnt = 0; dz->ptr_cnt = 0; dz->fptr_cnt = 0; break;
  98. case(TSTRETCH): dz->array_cnt =2; dz->iarray_cnt = 0; dz->larray_cnt = 0; dz->ptr_cnt =4; dz->fptr_cnt = 0; break;
  99. }
  100. /*** WARNING ***
  101. ANY APPLICATION DEALING WITH A NUMLIST INPUT: MUST establish AT LEAST 1 double array: i.e. dz->array_cnt = at least 1
  102. **** WARNING ***/
  103. if(dz->array_cnt < 0 || dz->iarray_cnt < 0 || dz->larray_cnt < 0 || dz->ptr_cnt < 0 || dz->fptr_cnt < 0) {
  104. sprintf(errstr,"array_cnt not set in setup_internal_arrays_and_array_pointers()\n");
  105. return(PROGRAM_ERROR);
  106. }
  107. if(dz->array_cnt > 0) {
  108. if((dz->parray = (double **)malloc(dz->array_cnt * sizeof(double *)))==NULL) {
  109. sprintf(errstr,"INSUFFICIENT MEMORY for internal double arrays.\n");
  110. return(MEMORY_ERROR);
  111. }
  112. for(n=0;n<dz->array_cnt;n++)
  113. dz->parray[n] = NULL;
  114. }
  115. if(dz->iarray_cnt > 0) {
  116. if((dz->iparray = (int **)malloc(dz->iarray_cnt * sizeof(int *)))==NULL) {
  117. sprintf(errstr,"INSUFFICIENT MEMORY for internal int arrays.\n");
  118. return(MEMORY_ERROR);
  119. }
  120. for(n=0;n<dz->iarray_cnt;n++)
  121. dz->iparray[n] = NULL;
  122. }
  123. if(dz->larray_cnt > 0) {
  124. if((dz->lparray = (int **)malloc(dz->larray_cnt * sizeof(int *)))==NULL) {
  125. sprintf(errstr,"INSUFFICIENT MEMORY for internal long arrays.\n");
  126. return(MEMORY_ERROR);
  127. }
  128. for(n=0;n<dz->larray_cnt;n++)
  129. dz->lparray[n] = NULL;
  130. }
  131. if(dz->ptr_cnt > 0) {
  132. if((dz->ptr = (double **)malloc(dz->ptr_cnt * sizeof(double *)))==NULL) {
  133. sprintf(errstr,"INSUFFICIENT MEMORY for internal pointer arrays.\n");
  134. return(MEMORY_ERROR);
  135. }
  136. for(n=0;n<dz->ptr_cnt;n++)
  137. dz->ptr[n] = NULL;
  138. }
  139. if(dz->fptr_cnt > 0) {
  140. if((dz->fptr = (float **)malloc(dz->fptr_cnt * sizeof(float *)))==NULL) {
  141. sprintf(errstr,"INSUFFICIENT MEMORY for internal float-pointer arrays.\n");
  142. return(MEMORY_ERROR);
  143. }
  144. for(n=0;n<dz->fptr_cnt;n++)
  145. dz->fptr[n] = NULL;
  146. }
  147. return(FINISHED);
  148. }
  149. /****************************** ASSIGN_PROCESS_LOGIC *********************************/
  150. int assign_process_logic(dataptr dz)
  151. {
  152. switch(dz->process) {
  153. case(STRETCH): setup_process_logic(ANALFILE_ONLY, EQUAL_ANALFILE, ANALFILE_OUT, dz); break;
  154. case(TSTRETCH):
  155. switch(dz->mode) {
  156. case(TSTR_NORMAL):setup_process_logic(ANALFILE_ONLY, BIG_ANALFILE, ANALFILE_OUT, dz); break;
  157. case(TSTR_LENGTH):setup_process_logic(ANALFILE_ONLY, SCREEN_MESSAGE, NO_OUTPUTFILE, dz); break;
  158. }
  159. break;
  160. default:
  161. sprintf(errstr,"Unknown process: assign_process_logic()\n");
  162. return(PROGRAM_ERROR);
  163. break;
  164. }
  165. if(dz->has_otherfile) {
  166. switch(dz->input_data_type) {
  167. case(ALL_FILES):
  168. case(TWO_SNDFILES):
  169. case(SNDFILE_AND_ENVFILE):
  170. case(SNDFILE_AND_BRKFILE):
  171. case(SNDFILE_AND_UNRANGED_BRKFILE):
  172. case(SNDFILE_AND_DB_BRKFILE):
  173. break;
  174. case(MANY_SNDFILES):
  175. if(dz->process==INFO_TIMELIST)
  176. break;
  177. /* fall thro */
  178. default:
  179. sprintf(errstr,"Most processes accepting files with different properties\n"
  180. "can only take 2 sound infiles.\n");
  181. return(PROGRAM_ERROR);
  182. }
  183. }
  184. return(FINISHED);
  185. }
  186. /***************************** SET_LEGAL_INFILE_STRUCTURE **************************
  187. *
  188. * Allows 2nd infile to have different props to first infile.
  189. */
  190. void set_legal_infile_structure(dataptr dz)
  191. {
  192. switch(dz->process) {
  193. default:
  194. dz->has_otherfile = FALSE;
  195. break;
  196. }
  197. }
  198. /***************************************************************************************/
  199. /****************************** FORMERLY IN internal.c *********************************/
  200. /***************************************************************************************/
  201. /****************************** SET_LEGAL_INTERNALPARAM_STRUCTURE *********************************/
  202. int set_legal_internalparam_structure(int process,int mode,aplptr ap)
  203. {
  204. int exit_status = FINISHED;
  205. switch(process) {
  206. case(STRETCH): exit_status = set_internalparam_data("idd",ap); break;
  207. case(TSTRETCH): exit_status = set_internalparam_data("di",ap); break;
  208. default:
  209. sprintf(errstr,"Unknown process in set_legal_internalparam_structure()\n");
  210. return(PROGRAM_ERROR);
  211. }
  212. return(exit_status);
  213. }
  214. /********************************************************************************************/
  215. /********************************** FORMERLY IN specialin.c *********************************/
  216. /********************************************************************************************/
  217. /********************** READ_SPECIAL_DATA ************************/
  218. int read_special_data(char *str,dataptr dz)
  219. {
  220. aplptr ap = dz->application;
  221. switch(ap->special_data) {
  222. default:
  223. sprintf(errstr,"Unknown special_data type: read_special_data()\n");
  224. return(PROGRAM_ERROR);
  225. }
  226. return(FINISHED); /* NOTREACHED */
  227. }
  228. /********************************************************************************************/
  229. /********************************** FORMERLY IN preprocess.c ********************************/
  230. /********************************************************************************************/
  231. /****************************** PARAM_PREPROCESS *********************************/
  232. int param_preprocess(dataptr dz)
  233. {
  234. switch(dz->process) {
  235. case(STRETCH): return set_internal_stretch_params(dz);
  236. case(TSTRETCH): return setup_internal_params_for_tstretch(dz);
  237. default:
  238. sprintf(errstr,"PROGRAMMING PROBLEM: Unknown process in param_preprocess()\n");
  239. return(PROGRAM_ERROR);
  240. }
  241. return(FINISHED); /* NOTREACHED */
  242. }
  243. /************ SET_INTERNAL_STRETCH_PARAMS *************/
  244. int set_internal_stretch_params(dataptr dz)
  245. {
  246. dz->param[STR_FFRQ] += dz->chwidth/2.0; /* set up FDCNO */
  247. dz->iparam[STR_FDCNO] = (int)floor(dz->param[STR_FFRQ]/dz->chwidth);
  248. if(dz->vflag[STR_IS_DEPTH]) {
  249. dz->param[STR_SL1] = dz->param[STR_SHIFT] - 1.0;
  250. if(dz->brksize[STR_DEPTH]==0)
  251. dz->param[STR_NSHIFT] = (dz->param[STR_SL1] * dz->param[STR_DEPTH]) + 1.0;
  252. } else
  253. dz->param[STR_NSHIFT] = dz->param[STR_SHIFT];
  254. return(FINISHED);
  255. }
  256. /************ SETUP_INTERNAL_PARAMS_FOR_TSTRETCH *************/
  257. int setup_internal_params_for_tstretch(dataptr dz)
  258. {
  259. int exit_status;
  260. if(dz->brksize[TSTR_STRETCH] && (exit_status = force_value_at_zero_time(TSTR_STRETCH,dz))<0)
  261. return(exit_status);
  262. dz->param[TSTR_TOTIME] = (double)dz->wlength * dz->frametime;
  263. /* dur of orig sound source */
  264. dz->iparam[TSTR_ARRAYSIZE] = POSMIN;
  265. if((dz->parray[TSTR_PBUF]
  266. = (double *)malloc(dz->iparam[TSTR_ARRAYSIZE] * sizeof(double)))==NULL) {
  267. sprintf(errstr,"INSUFFICIENT MEMORY for timestretch array.\n");
  268. return(MEMORY_ERROR);
  269. }
  270. dz->ptr[TSTR_PEND] = dz->parray[TSTR_PBUF] + dz->iparam[TSTR_ARRAYSIZE];
  271. if((dz->parray[TSTR_QBUF]
  272. = (double *)malloc(dz->iparam[TSTR_ARRAYSIZE] * sizeof(double)))==NULL) {
  273. sprintf(errstr,"INSUFFICIENT MEMORY for 2nd timestretch array.\n");
  274. return(MEMORY_ERROR);
  275. }
  276. return(FINISHED);
  277. }
  278. /********************************************************************************************/
  279. /********************************** FORMERLY IN procspec.c **********************************/
  280. /********************************************************************************************/
  281. /**************************** SPEC_PROCESS_FILE ****************************/
  282. int spec_process_file(dataptr dz)
  283. {
  284. dz->total_windows = 0;
  285. if(!(dz->process==TSTRETCH && dz->mode==TSTR_LENGTH))
  286. display_virtual_time(0L,dz);
  287. switch(dz->process) {
  288. case(STRETCH): return outer_loop(dz);
  289. case(TSTRETCH): return spectstretch(dz);
  290. default:
  291. sprintf(errstr,"Unknown process in procspec()\n");
  292. return(PROGRAM_ERROR);
  293. }
  294. return(FINISHED); /* NOTREACHED */
  295. }
  296. /**************************** INNER_LOOP ****************************/
  297. int inner_loop
  298. (int *peakscore,int *descnt,int *in_start_portion,int *least,int *pitchcnt,int windows_in_buf,dataptr dz)
  299. {
  300. int exit_status;
  301. int local_zero_set = FALSE;
  302. int wc;
  303. for(wc=0; wc<windows_in_buf; wc++) {
  304. if(dz->total_windows==0) {
  305. if((exit_status = skip_or_special_operation_on_window_zero(dz))<0)
  306. return(exit_status);
  307. if(exit_status==TRUE) {
  308. dz->flbufptr[0] += dz->wanted;
  309. dz->total_windows++;
  310. dz->time = (float)(dz->time + dz->frametime);
  311. continue;
  312. }
  313. }
  314. if((exit_status = read_values_from_all_existing_brktables((double)dz->time,dz))<0)
  315. return(exit_status);
  316. switch(dz->process) {
  317. case(STRETCH): exit_status = specstretch(dz); break;
  318. default:
  319. sprintf(errstr,"unknown process in inner_loop()\n");
  320. return(PROGRAM_ERROR);
  321. }
  322. if(exit_status<0)
  323. return(exit_status);
  324. dz->flbufptr[0] += dz->wanted;
  325. dz->total_windows++;
  326. dz->time = (float)(dz->time + dz->frametime);
  327. }
  328. if(!dz->zeroset && local_zero_set==TRUE) {
  329. fprintf(stdout,"WARNING: Zero-amp spectral window(s) encountered: orig window(s) substituted.\n");
  330. fflush(stdout);
  331. dz->zeroset = TRUE;
  332. }
  333. return(FINISHED);
  334. }
  335. /***************** SKIP_OR_SPECIAL_OPERATION_ON_WINDOW_ZERO ************/
  336. int skip_or_special_operation_on_window_zero(dataptr dz)
  337. {
  338. return(FALSE);
  339. }
  340. /********************************************************************************************/
  341. /********************************** FORMERLY IN pconsistency.c ******************************/
  342. /********************************************************************************************/
  343. /****************************** CHECK_PARAM_VALIDITY_AND_CONSISTENCY *********************************/
  344. int check_param_validity_and_consistency(dataptr dz)
  345. {
  346. handle_pitch_zeros(dz);
  347. switch(dz->process) {
  348. case(STRETCH): return check_viability_and_compatibility_of_stretch_params(dz);
  349. case(TSTRETCH): return check_for_enough_tstretch_brkpnt_vals(dz);
  350. }
  351. return(FINISHED);
  352. }
  353. /*************** CHECK_VIABILITY_AND_COMPATIBILITY_OF_STRETCH_PARAMS **********/
  354. int check_viability_and_compatibility_of_stretch_params(dataptr dz)
  355. {
  356. int exit_status;
  357. /* set up FDCNO for tests */
  358. double frq = dz->param[STR_FFRQ] + dz->chwidth/2.0;
  359. int fdcno = (int)floor(frq/dz->chwidth);
  360. if(flteq(dz->param[STR_SHIFT],1.0)) {
  361. sprintf(errstr,"Shift = 1. No change. Use your original source.\n");
  362. return(DATA_ERROR);
  363. }
  364. if(dz->vflag[STR_IS_DEPTH]) {
  365. if((exit_status = check_depth_vals(STR_DEPTH,dz)) <0)
  366. return(exit_status);
  367. }
  368. switch(dz->mode) {
  369. case(STRETCH_ABOVE):
  370. if(dz->param[STR_SHIFT] > 1.0
  371. && round((double)(dz->clength-1)/dz->param[STR_SHIFT]) < fdcno) {
  372. sprintf(errstr,"Maxstretch incompatible with frq_split.\n");
  373. return(DATA_ERROR);
  374. }
  375. if(dz->param[STR_SHIFT] <= 1.0
  376. && round((double)(dz->clength-1)*dz->param[STR_SHIFT]) < fdcno) {
  377. sprintf(errstr,"Maxstretch incompatible with frq_split.\n");
  378. return(DATA_ERROR);
  379. }
  380. break;
  381. case(STRETCH_BELOW):
  382. if(dz->param[STR_SHIFT] >= (double)fdcno) {
  383. sprintf(errstr,"Maxstretch incompatible with frq_split.\n");
  384. return(DATA_ERROR);
  385. }
  386. if(dz->param[STR_SHIFT] <= 1.0
  387. && 1.0/dz->param[STR_SHIFT] >= (double)fdcno) {
  388. sprintf(errstr,"Maxstretch incompatible with frq_split.\n");
  389. return(DATA_ERROR);
  390. }
  391. break;
  392. default:
  393. sprintf(errstr,"Unknown spec stretch mode in check_stretch_params()\n");
  394. return(PROGRAM_ERROR);
  395. }
  396. return(FINISHED);
  397. }
  398. /********************* CHECK_FOR_ENOUGH_TSTRETCH_BRKPNT_VALS **********************/
  399. int check_for_enough_tstretch_brkpnt_vals(dataptr dz)
  400. {
  401. if(dz->brksize[TSTR_STRETCH] && dz->brksize[TSTR_STRETCH] < 2) {
  402. sprintf(errstr,"Not enough data in tsretch data file.\n");
  403. return(DATA_ERROR);
  404. }
  405. return(FINISHED);
  406. }
  407. /********************************************************************************************/
  408. /********************************** FORMERLY IN buffers.c ***********************************/
  409. /********************************************************************************************/
  410. /**************************** ALLOCATE_LARGE_BUFFERS ******************************/
  411. int allocate_large_buffers(dataptr dz)
  412. {
  413. switch(dz->process) {
  414. case(STRETCH):
  415. return allocate_single_buffer(dz);
  416. case(TSTRETCH):
  417. if(dz->mode==TSTR_NORMAL)
  418. return allocate_tstretch_buffer(dz);
  419. return(FINISHED);
  420. default:
  421. sprintf(errstr,"Unknown program no. in allocate_large_buffers()\n");
  422. return(PROGRAM_ERROR);
  423. }
  424. return(FINISHED); /* NOTREACHED */
  425. }
  426. /*************************** ALLOCATE_TSTRETCH_BUFFER ****************************/
  427. int allocate_tstretch_buffer(dataptr dz)
  428. {
  429. unsigned int buffersize;
  430. if(dz->bptrcnt < 6) {
  431. sprintf(errstr,"Insufficient bufptrs established in allocate_tstretch_buffer()\n");
  432. return(PROGRAM_ERROR);
  433. }
  434. //TW REVISED: multiplle of LCM no longer required
  435. buffersize = dz->wanted * BUF_MULTIPLIER;
  436. dz->buflen = buffersize;
  437. buffersize *= 2;
  438. buffersize += dz->wanted;
  439. if((dz->bigfbuf = (float *)malloc((size_t)(buffersize * sizeof(float))))==NULL) {
  440. sprintf(errstr,"INSUFFICIENT MEMORY for sound buffers.\n");
  441. return(MEMORY_ERROR);
  442. }
  443. dz->big_fsize = dz->buflen;
  444. dz->flbufptr[0] = dz->bigfbuf + dz->wanted; /* inbuf */
  445. dz->flbufptr[1] = dz->flbufptr[0] + dz->big_fsize; /* outbuf & inbufend */
  446. dz->flbufptr[2] = dz->flbufptr[1] + dz->big_fsize; /* outbufend */
  447. dz->flbufptr[3] = dz->flbufptr[0]; /* 1st inbuf pointer */
  448. dz->flbufptr[4] = dz->flbufptr[0] + dz->wanted; /* 2nd inbuf pointer */
  449. dz->flbufptr[5] = dz->flbufptr[1]; /* outbuf ptr */
  450. return(FINISHED);
  451. }
  452. /********************************************************************************************/
  453. /********************************** FORMERLY IN cmdline.c ***********************************/
  454. /********************************************************************************************/
  455. int get_process_no(char *prog_identifier_from_cmdline,dataptr dz)
  456. {
  457. if (!strcmp(prog_identifier_from_cmdline,"spectrum")) dz->process = STRETCH;
  458. else if(!strcmp(prog_identifier_from_cmdline,"time")) dz->process = TSTRETCH;
  459. else {
  460. sprintf(errstr,"Unknown program identification string '%s'\n",prog_identifier_from_cmdline);
  461. return(USAGE_ONLY);
  462. }
  463. //TW UPDATE
  464. return(FINISHED);
  465. }
  466. /********************************************************************************************/
  467. /********************************** FORMERLY IN usage.c *************************************/
  468. /********************************************************************************************/
  469. /******************************** USAGE1 ********************************/
  470. int usage1(void)
  471. {
  472. sprintf(errstr,
  473. "\nSTRETCHING A SPECTRAL FILE\n\n"
  474. "USAGE: stretch NAME (mode) infile outfile parameters: \n"
  475. "\n"
  476. "where NAME can be any one of\n"
  477. "spectrum time\n\n"
  478. "Type 'stretch spectrum' for more info on stretch spectrum..ETC.\n");
  479. return(USAGE_ONLY);
  480. }
  481. /******************************** USAGE2 ********************************/
  482. int usage2(char *str)
  483. {
  484. if(!strcmp(str,"spectrum")) { /* STRETCH */
  485. fprintf(stdout,
  486. "stretch spectrum mode infile outfile frq_divide maxstretch exponent [-ddepth]\n"
  487. "\n"
  488. "STRETCH THE FREQUENCIES IN THE SPECTRUM\n"
  489. "\n"
  490. "MODES:-\n"
  491. "1 Stretch above the frq_divide.\n"
  492. "2 Stretch below the frq_divide.\n"
  493. "\n"
  494. "frq_divide is the frq above or below which spectral stretching takes place.\n"
  495. "maxstretch is the transposition ratio of the topmost spectral components.\n"
  496. "exponent specifies the type of stretching required. (> 0)\n"
  497. "depth stretch effect on source (from 0 (no effect) to 1 (full effect))\n\n"
  498. "depth can vary over time.\n");
  499. } else if(!strcmp(str,"time")) { /* TSTRETCH */
  500. sprintf(errstr,
  501. "stretch time 1 infile outfile timestretch\n"
  502. "stretch time 2 infile timestretch\n"
  503. "\n"
  504. "TIME-STRETCHING OF INFILE.\n"
  505. "In mode 2, program calculates length of output, only."
  506. "\n"
  507. "Timestretch may itself vary over time.\n");
  508. } else
  509. sprintf(errstr,"Unknown option '%s'\n",str);
  510. return(USAGE_ONLY);
  511. }
  512. /******************************** USAGE3 ********************************/
  513. int usage3(char *str1,char *str2)
  514. {
  515. //TW AVOID WARNINGS
  516. // str1 = str1;
  517. // str2 = str2;
  518. sprintf(errstr,"Insufficient parameters on command line.\n");
  519. return(USAGE_ONLY);
  520. }