structures.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. * Copyright (c) 1983-2013 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. /* floatsam version */
  22. /*********************************************/
  23. /* STORAGE OF DUPLICATE HEADERS IN SFRECOVER */
  24. /*********************************************/
  25. #ifndef _STRUCTURES_H_INCLUDED
  26. #define _STRUCTURES_H_INCLUDED
  27. #include <sfsys.h> /* for CHPEAK */
  28. struct hhead {
  29. char *addr;
  30. short cnt;
  31. };
  32. typedef struct hhead *headptr;
  33. /*******************************************/
  34. /* ELEMENTS IN PLAYLIST FOR MAKING TEXTURE */
  35. /*******************************************/
  36. struct soundout {
  37. float *inbuf;
  38. unsigned int ibufcnt;
  39. unsigned int st_sstttime;
  40. unsigned int st_sendtime;
  41. unsigned int obufpos;
  42. int st_splicpos;
  43. double ibufpos;
  44. double step;
  45. double lgain;
  46. double rgain;
  47. struct soundout *next;
  48. struct soundout *last;
  49. };
  50. typedef struct soundout *sndoutptr;
  51. /*************************************************/
  52. /* STORE CHAN DATA IN RINGBUF (TRACE,SUPR etc) */
  53. /*************************************************/
  54. struct chanval {
  55. float val;
  56. int loc;
  57. struct chanval *next;
  58. struct chanval *last;
  59. };
  60. typedef struct chanval *chvptr;
  61. /*************************************************/
  62. /* STORE LOUDEST-CHANNEL DATA (BLTR) */
  63. /*************************************************/
  64. struct chanstore {
  65. float amp;
  66. int chan;
  67. };
  68. typedef struct chanstore *chsptr;
  69. /*************************************************/
  70. /* STORES SPEC SPLIT BANDING DATA */
  71. /*************************************************/
  72. struct bandd {
  73. int bdoflag; /*RWD these two were short */
  74. int badditive;
  75. double bfrqlo;
  76. double bfrqhi;
  77. double bfrqdif;
  78. double bamp;
  79. double bampdif;
  80. double btrans;
  81. };
  82. typedef struct bandd *bandptr;
  83. /*************************************************/
  84. /* WHICH CHANS ARE PEAKS, & HOW OFTEN (FOCU) */
  85. /*************************************************/
  86. struct design {
  87. int chan;
  88. int score;
  89. double amp;
  90. };
  91. typedef struct design *desptr;
  92. /*************************************************/
  93. /* FOCU: DATA FOR CALCULATING STABILITY OF PEAKS */
  94. /*************************************************/
  95. struct stability {
  96. int offset;
  97. float *sbufstore;
  98. float *specstore;
  99. float **sbuf; /* pointers to windows within it */
  100. float **spec;
  101. int *fpkstore; /* baktraking spectral-peaks buffer */
  102. int *total_pkcnt; /* count of total peaks found per baktrak buffer */
  103. int *design_score; /* array for designing filter */
  104. int **fpk; /* pointers to peakstores within it */
  105. desptr *des;
  106. };
  107. typedef struct stability *stabptr;
  108. /*******************************************/
  109. /* ELEMENTS IN NOTELIST, STORING NOTE DATA */
  110. /*******************************************/
  111. struct nnote {
  112. float pitch;
  113. float amp;
  114. float dur;
  115. float ntime;
  116. float spacepos;
  117. float motioncentre;
  118. unsigned char instr;
  119. struct nnote *next;
  120. struct nnote *last;
  121. };
  122. typedef struct nnote *noteptr;
  123. /**********************************************/
  124. /* ELEMENTS IN MOTIFLIST, STORING NOTE-MOTIFS */
  125. /**********************************************/
  126. struct motif {
  127. noteptr firstnote;
  128. struct motif *next;
  129. struct motif *last;
  130. };
  131. typedef struct motif *motifptr;
  132. /*************************************************/
  133. /* PROPERTIES OF INPUT FILES, FOR TEXTURE APPLICS*/
  134. /*************************************************/
  135. struct insample {
  136. float *buffer;
  137. double pitch;
  138. };
  139. typedef struct insample *insamptr;
  140. /***********************************************/
  141. /* ADDITIONAL DATA STORAGE FOR TEXTURE APPLICS */
  142. /***********************************************/
  143. struct textural {
  144. unsigned int txflag;
  145. motifptr motifhead;
  146. motifptr timeset;
  147. motifptr hfldmotif;
  148. motifptr *phrase;
  149. insamptr *insnd;
  150. int **perm;
  151. unsigned char dectypstor;
  152. unsigned char dectypcnt;
  153. unsigned char amptypstor;
  154. unsigned char amptypcnt;
  155. int phrasecnt;
  156. int ampdirectd;
  157. };
  158. typedef struct textural *texptr;
  159. /***********************************************/
  160. /* DATA STORAGE FOR MIXING ACTIONS */
  161. /***********************************************/
  162. struct actval {
  163. int ifd; /* file from which to read samples */
  164. int bufno; /* these must be assigned before we start using this struct */
  165. int samplen; /* number of samples produced from whole file */
  166. double llscale; /* this is left weighting of left-inchan * 32768 */
  167. double lrscale; /* this is right weighting of left-inchan * 32768 */
  168. double rlscale; /* this is left weighting of right-inchan * 32768 */
  169. double rrscale; /* this is right weighting of right-inchan * 32768 */
  170. int stereo; /* mono, stereo, mono-to-stereo, stereo_panned */
  171. } ;
  172. typedef struct actval *actvalptr;
  173. /***********************************************/
  174. /* MIXING ACTIONS */
  175. /***********************************************/
  176. struct action {
  177. int position; /* time of action, in samples */
  178. actvalptr val; /* all associated values, stored in an actval */
  179. int role; /* ON , REFILL, or OFF */
  180. } ;
  181. typedef struct action *actptr;
  182. /***********************************************/
  183. /* MIXING BUFFERS */
  184. /***********************************************/
  185. struct bufitem {
  186. short status; /* Buffer is in use or not */
  187. float *buf; /* Location of buffer */
  188. float *here; /* Location in buffer */
  189. } ;
  190. typedef struct bufitem *mixbufptr;
  191. /***********************************************/
  192. /* APPLICATION (Possibly only for CMDLINE?? */
  193. /***********************************************/
  194. struct applic {
  195. char max_param_cnt; /* Max number of parameter taken by prog */
  196. char internal_param_cnt; /* Number of internal parameters */
  197. /****** ENTRY OF DATA TO PROGRAM ******/
  198. char formant_flag; /* Indicates whether formant data is entered */
  199. char formant_qksrch; /* Indicates alternative formant calculation */
  200. char **param_name;
  201. char **flagname;
  202. char *special_data_name;
  203. char *special_data_name2;
  204. char special_data; /* Indicates if (and which) special data (pitch,filter params etc) is used by prog */
  205. int special_range; /* Flag when range of special_data can be displayed in dialog-box */
  206. int other_special_range; /* Flag when range of 2nd item of special_data CAN be displayed */
  207. int data_in_file_only;
  208. int input_process_type;
  209. int accepts_conflicting_srates;
  210. double min_special; /* range for special_data */
  211. double max_special;
  212. double default_special; /* default value of special_data */
  213. double min_special2; /* range for 2nd item of special_data */
  214. double max_special2;
  215. int no_pitchwise_formants;
  216. int min_fbands;
  217. int max_freqwise_fbands;
  218. int max_pichwise_fbands;
  219. int no_pichwise_formants;
  220. char param_cnt; /* Number of parameter taken by prog */
  221. char option_cnt; /* Number of options on options menu, or cmdline */
  222. char vflag_cnt; /* Total number of variants in menu, or possible on cmdline */
  223. char variant_param_cnt; /* Number of variants with parameters */
  224. char total_input_param_cnt;
  225. char* display_type; /* normal, log etc */
  226. char* has_subrange;
  227. /* total number of params that can be input, including options & variants */
  228. /* PARAMETER TYPE (int, double, brkpnt. brkpnt-int) for ... */
  229. double *lo; /* parameter range min */
  230. double *hi; /* parameter range max */
  231. double *default_val; /* parameter range max */
  232. double *lolo; /* displayed parameter range min */
  233. double *hihi; /* displayed parameter range max */
  234. char *param_list; /* each param in turn */
  235. char *option_list; /* each option in turn */
  236. char *variant_list; /* each variant in turn */
  237. char *internal_param_list; /* internal param types */
  238. /* CMDLINE FLAGS */
  239. char *option_flags; /* Cmdline flags used to differentiate options */
  240. char *variant_flags; /* Cmdline flags used to differentiate variants */
  241. };
  242. typedef struct applic *aplptr;
  243. /***********************************************/
  244. /* INFILE DATA STORAGE AT PARSING */
  245. /***********************************************/
  246. /* RWD FEB 2010: need unsigned values for file sizes */
  247. struct filedata {
  248. int filetype;
  249. /* FILE DESCRIPTOR AND SIZES */
  250. /*unsigned*/ int infilesize;
  251. /*unsigned*/ int insams; /*RWD FEB 2010 */
  252. /* FILE PROPERTIES */
  253. int srate; /* cdp file properties */
  254. int channels;
  255. int stype;
  256. int origstype;
  257. int origrate;
  258. int Mlen;
  259. int Dfac;
  260. int origchans;
  261. int specenvcnt;
  262. int wanted; /* floats per window */
  263. int wlength; /* length in windows */
  264. int out_chans; /* outchans of mixfile */
  265. int descriptor_samps;
  266. /* FLAGS */
  267. int is_transpos; /* flags transpos, rather than pitch, in floatarray */
  268. int could_be_transpos; /* flags textfile data COULD be transpos data */
  269. int could_be_pitch; /* flags textfile data COULD be pitch data */
  270. int different_srates; /* flags program can accept insnds of different srates */
  271. int duplicate_snds; /* flags there are duplicated sndfiles in mixfile */
  272. /* COUNTERS */
  273. int brksize; /* (paired) size of brkpnt data */
  274. int numsize; /* unpaired size of numeric data */
  275. /* TEXTFILE DATA */
  276. int linecnt; /* number of lines */
  277. int all_words; /* number of words */
  278. float arate;
  279. float frametime; /* duration of window */
  280. float window_size; /* duration of (envelope) window */
  281. double nyquist;
  282. /* BRKPNT DATA */
  283. double duration; /* duration of brkpnt data */
  284. double minbrk;
  285. double maxbrk;
  286. double minnum;
  287. double maxnum;
  288. };
  289. typedef struct filedata *infileptr;
  290. /***********************************************/
  291. /* INFILE PROPERTIES STORAGE */
  292. /***********************************************/
  293. struct fileprops {
  294. int filetype;
  295. int srate;
  296. int stype;
  297. int origstype;
  298. int origrate;
  299. int channels;
  300. int origchans; /* pitch, formant,transpos only */
  301. int specenvcnt; /* formants only */
  302. int Mlen;
  303. int Dfac;
  304. float arate;
  305. float window_size; /* duration of (envelope) window */
  306. };
  307. typedef struct fileprops *fileptr;
  308. /***********************************************/
  309. /* PROGRAM PRINCIPAL STRUCTURE */
  310. /***********************************************/
  311. struct datalist {
  312. int process; /* which application is being run */
  313. int maxmode; /* number of modes of operation of process */
  314. int mode; /* actual mode of operation of process */
  315. /* PROCESS TYPES */
  316. int input_data_type;
  317. int outfiletype;
  318. int process_type;
  319. char *outfilename; /* need this for synth */
  320. /*RWD.10.98 force floatsam outfile*/
  321. int floatsam_output;
  322. double peak_fval;
  323. int true_outfile_stype;
  324. int clip_floatsams;
  325. /* all this is to do with PEAK handling! */
  326. int outchans;
  327. int otheroutchans;
  328. int needpeaks;
  329. int needotherpeaks;
  330. CHPEAK *outpeaks; /* for running PEAK counting */
  331. CHPEAK *otherpeaks; /* for 'otherfile' output;*/
  332. unsigned int *outpeakpos; /* tracking position of peak, for each channel */
  333. unsigned int *otherpeakpos;
  334. /* APPLICATION */
  335. aplptr application; /* structure to store details of particular process */
  336. /* BUFFERS */
  337. float *bigbuf; /* internal large buffer */
  338. float **sampbuf; /* buffer starts and ends */
  339. float **sbufptr; /* buffer pointers */
  340. float *bigfbuf; /* internal large buffer for floats */
  341. float **flbufptr; /* buffer pointers for float bufs */
  342. float **windowbuf; /* additional window_size buffers for floats */
  343. float **extrabuf; /* extra non-standard-length snd-buffer pointers */
  344. float **extrabufptr; /* extra_buffer pointers */
  345. float *amp;
  346. float *freq;
  347. /* BRKPNT TABLES */
  348. double **brk;
  349. double **brkptr;
  350. int *brksize;
  351. double *lastind;
  352. double *lastval;
  353. int *brkinit;
  354. double *firstval;
  355. /* PARAMETERS */
  356. double *param; /* parameter storage */
  357. int *iparam; /* integer parameter storage */
  358. char *vflag; /* internal program flags set by variants in cmdline/menu */
  359. /* PARAMETER MARKERS */
  360. char *is_int; /* mark integer parameters, INCLUDING internal parameters */
  361. char *no_brk; /* mark parameters which cannot be entered as brkpntfiles */
  362. char *is_active; /* mark parameters which COULD actually be in use */
  363. /* ARRAYS */
  364. double **parray; /* parameter array storage */
  365. int **iparray; /* integer parameter array storage */
  366. /* RWD used for submix syncatt instead of lparray */
  367. float **lfarray;
  368. int **lparray; /* int parameter array storage */
  369. float *sndbuf; /* short parameter array storage, for (pseudo) snd output */
  370. /* INTERNAL POINTERS */
  371. /*TW NAME CHANGE, TO avoid possible future error (lptrs were paired with lparrays)*/
  372. float **fptr; /* misc pointers to floats */
  373. double **ptr; /* misc pointers to doubles */
  374. /* FILE PROPERTY STORES */
  375. fileptr infile; /* first infile */
  376. fileptr outfile; /* main outfile */
  377. fileptr otherfile; /* 2nd infile which CAN have different sr, chans */
  378. /* INFILE POINTERS AND SIZES */
  379. int *ifd;
  380. /*int *infilesize;*/
  381. int *insams;
  382. /* FORMANT ARRAYS */
  383. float *specenvfrq;
  384. float *specenvpch;
  385. float *specenvamp;
  386. float *specenvtop;
  387. float *specenvamp2;
  388. /* FOR PITCH CONTOUR, TRANSPOSITION OR CHORDS */
  389. float *pitches;
  390. float *transpos;
  391. float *pitches2;
  392. float *transpos2;
  393. float *frq_template;
  394. /* FOR FILTERS */
  395. float *fsampbuf;
  396. double *filtpeak;
  397. double *fbandtop;
  398. double *fbandbot;
  399. int *peakno;
  400. int *lastpeakno;
  401. /* SPECIAL PURPOSE */
  402. bandptr *band; /* for SPLIT */
  403. stabptr stable; /* for FOCUS */
  404. chsptr loudest; /* FOR BLTR */
  405. chvptr ringhead; /* FOR SUPR and TRACE & PITCH */
  406. chvptr ringhead2; /* FOR MEAN */
  407. double *temp;
  408. /* ENVELOPES */
  409. float *origenv;
  410. float *origend;
  411. float *env;
  412. float *envend;
  413. double *rampbrk;
  414. /* MIXFILE */
  415. actvalptr *valstor;
  416. actptr *act;
  417. mixbufptr *buflist;
  418. int *activebuf;
  419. float **activebuf_ptr;
  420. /* TEXTTURE */
  421. texptr tex;
  422. /* TEXTFILES */
  423. int *wordcnt;
  424. char **wordstor;
  425. FILE *fp;
  426. /* OTHER FILE PONTERS */
  427. int ofd;
  428. int other_file;
  429. /* DATA OR PROCESS CONSTANTS */
  430. int outfilesize;
  431. /*int bigbufsize;*/
  432. /*int bigbufsize2; */
  433. int buflen2;
  434. int big_fsize;
  435. int buflen;
  436. int linecnt;
  437. int all_words;
  438. int extra_word;
  439. int numsize;
  440. int wanted;
  441. /*int byteswanted; */
  442. int sampswanted;
  443. int wlength;
  444. int clength;
  445. int infilecnt;
  446. int bptrcnt;
  447. int bufcnt; /* buffers used by SND programs */
  448. int extra_bufcnt; /* extra_buffers used by SND programs */
  449. int array_cnt;
  450. int iarray_cnt;
  451. int larray_cnt;
  452. /*TW NAME CHANGE*/
  453. /*int lptr_cnt;*/
  454. int fptr_cnt;
  455. int ptr_cnt;
  456. int formant_bands;
  457. int specenvcnt;
  458. /*int descriptor_bytes;*/
  459. int descriptor_samps;
  460. int out_chans;
  461. int extrabrkno;
  462. double nyquist;
  463. double chwidth;
  464. double halfchwidth;
  465. double minbrk;
  466. double maxbrk;
  467. double minnum;
  468. double maxnum;
  469. double duration;
  470. /* COUNTERS */
  471. int total_windows;
  472. int total_samps_written;
  473. /*int total_bytes_written;*/
  474. /*int bytes_left;*/
  475. int samps_left;
  476. int ssampsread;
  477. int total_samps_read;
  478. /*int bytes_read;*/
  479. /*int samps_read; */ /*RWD just use ssampsread */
  480. /*int total_bytes_read;*/
  481. int itemcnt;
  482. int ringsize;
  483. int tempsize; /*RWD need both? */
  484. int temp_sampsize; /*RWD my addition for housekeep channels*/
  485. int rampbrksize;
  486. /* TIMERS */
  487. float time;
  488. float timemark;
  489. float frametime;
  490. /* OTHER */
  491. double scalefact;
  492. double is_sharp;
  493. double is_flat;
  494. /* FLAGS */
  495. int specenv_type;
  496. int deal_with_chan_data;
  497. int different_srates;
  498. int duplicate_snds;
  499. int unspecified_filecnt;
  500. int has_otherfile;
  501. int is_transpos;
  502. int could_be_transpos;
  503. int could_be_pitch;
  504. int finished;
  505. int zeroset;
  506. int fzeroset;
  507. int is_mapping;
  508. int is_rectified;
  509. /*RWD */
  510. /*int snd_ofd;*/
  511. /*int snd_ifd;*/ /* just the one */
  512. };
  513. typedef struct datalist *dataptr;
  514. #endif