tkglobals.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * Copyright (c) 1983-2023 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. /*******************************************************************************************
  22. * TO COMPILE TKLIB4 : COMMENT OUT (ONLY) the 2nd PAIR OF LINES BELOW
  23. * TO COMPILE CDPARSE: COMMENT OUT (ONLY) the 1st PAIR OF LINES BELOW
  24. *******************************************************************************************/
  25. /*RWD we do ALL THIS at COMPILER LEVEL NOW! */
  26. /**
  27. #define IS_CDPMAIN (1)
  28. #undef IS_CDPARSE
  29. **/
  30. /**
  31. #define IS_CDPARSE (1)
  32. #undef IS_CDPMAIN
  33. **/
  34. /* RWD BUT: we can do this for convenience... */
  35. #ifndef IS_CDPARSE
  36. #define IS_CDPMAIN
  37. #endif
  38. /*******************************************************************************************/
  39. #include <math.h>
  40. #include <headread.h>
  41. #include <cdpstate.h>
  42. #ifdef _WIN32
  43. # ifdef FAILED
  44. # undef FAILED
  45. # undef SUCCEEDED
  46. # endif
  47. #endif
  48. #define FAILED (-1) /* check with Ambrose ???? */
  49. #define SUCCEEDED (0) /* check with Ambrose ???? */
  50. /*******************************************************************************************
  51. * COMPUTER SYSTEM
  52. *******************************************************************************************/
  53. /*RWD: I want this confined to the library somehow... */
  54. #ifdef _WIN32
  55. #define IS_PC (1)
  56. #endif
  57. #ifdef unix
  58. #define IS_UNIX (1)
  59. #define _MAX_PATH (255)
  60. #endif
  61. #if !defined IS_PC && !defined IS_UNIX
  62. #error CDP2K (tkglobals.h) Error: no platform defined
  63. #endif
  64. /*******************************************************************************************
  65. * TYPE OF CDP OUTPUT: FOR CMDLINE OR SOUNDLOOM GRAPHIC INTERFACE
  66. *******************************************************************************************/
  67. #ifdef IS_PC
  68. #ifdef _MSC_VER
  69. #pragma warning (disable : 4032)
  70. #pragma warning (disable: 4100)
  71. #pragma warning (disable: 4702)
  72. #endif
  73. #include <conio.h> /* respond to keyboard */
  74. #endif
  75. #define F_SECSIZE (256)
  76. #ifdef IS_CDPMAIN
  77. /*******************************************************************************************
  78. * FUNCTIONS GLOBAL TO CDPARSE, CDPARAMS and CDPMAIN
  79. *******************************************************************************************/
  80. #define NOT_SET (0) /* Cannot be changed from 0, see modify-brasssage constants list */
  81. int get_maxmode(int process);
  82. int allocate_and_initialise_validity_flags(int **valid,int *validcnt);
  83. int establish_application_validities(int filetype,int channels,int *valid);
  84. int valid_application(int process,int *valid);
  85. int assign_input_process_type(int process,int mode,int *inprocess_type);
  86. int setup_input_param_range_stores(int total_params,aplptr ap);
  87. int set_param_ranges(int process,int mode,double nyquist,float frametime,float arate,int srate,
  88. int wlength,int insams,int channels,int wanted,
  89. int filetype,int linecnt,double duration,aplptr ap);
  90. int set_legal_param_structure(int process,int mode,aplptr ap);
  91. int set_legal_option_and_variant_structure(int process,int mode,aplptr ap);
  92. void set_formant_flags(int process,int mode,aplptr ap);
  93. int initialise_param_values(int process,int mode,int channels,double nyquist,float frametime,
  94. int insams,int srate,int wanted,int linecnt,double duration,double *default_val,int filetype,aplptr ap);
  95. int cdparse(char *filename,infileptr inputfile);
  96. int setup_special_data_ranges(int mode,int srate,double duration,double nyquist,int wlength,int channels,aplptr ap);
  97. int readhead(infileptr inputfile,int ifd,char *filename,double *maxamp,double *maxloc, int *maxrep,int getmax,int getmaxinfo);
  98. int is_a_valid_input_filetype(int filetype);
  99. int is_a_valid_file_for_process(int filetype,int input_data_type);
  100. int is_a_text_input_filetype(int filetype);
  101. int is_a_textfile_type(int filetype); /* after type conversion: not at input */
  102. int could_be_transpos_and_or_pitch_infiletype(int filetype);
  103. int is_brkfile_infiletype(int filetype);
  104. int is_numlist_infiletype(int filetype);
  105. int is_transpos_infiletype(int filetype);
  106. int is_pitch_infiletype(int filetype);
  107. int is_sndlist_only_infiletype(int filetype);
  108. void rectify_window(float *flbuf,dataptr dz);
  109. int tkusage(int process,int mode);
  110. void print_outmessage(char *str);
  111. void print_outmessage_flush(char *str);
  112. void print_outwarning_flush(char *str);
  113. //TW NEW
  114. int value_is_numeric(char *str);
  115. //TW NEW
  116. #define VOWEL_STRING (-6)
  117. #define INTERVAL_STRING (-5)
  118. #define NOTE_STRING (-4)
  119. #define REORDER_STRING (-3)
  120. #define SHUFFLE_STRING (-2)
  121. #define SNDFILENAME_STRING (-1)
  122. /* data stored in TK */
  123. #define CDP_PROPS_CNT (34)
  124. #define INPUT_FILETYPE (0)
  125. #define INPUT_FILESIZE (1)
  126. #define INPUT_INSAMS (2)
  127. #define INPUT_SRATE (3)
  128. #define INPUT_CHANNELS (4)
  129. #define INPUT_WANTED (5)
  130. #define INPUT_WLENGTH (6)
  131. #define INPUT_LINECNT (7)
  132. #define INPUT_ARATE (8)
  133. #define INPUT_FRAMETIME (9)
  134. #define INPUT_NYQUIST (10)
  135. #define INPUT_DURATION (11)
  136. #define INPUT_STYPE (12)
  137. #define INPUT_ORIGSTYPE (13)
  138. #define INPUT_ORIGRATE (14)
  139. #define INPUT_MLEN (15)
  140. #define INPUT_DFAC (16)
  141. #define INPUT_ORIGCHANS (17)
  142. #define INPUT_SPECENVCNT (18)
  143. #define INPUT_OUT_CHANS (19)
  144. #define INPUT_DESCRIPTOR_BYTES (20)
  145. #define INPUT_IS_TRANSPOS (21)
  146. #define INPUT_COULD_BE_TRANSPOS (22)
  147. #define INPUT_COULD_BE_PITCH (23)
  148. #define INPUT_DIFFERENT_SRATES (24)
  149. #define INPUT_DUPLICATE_SNDS (25)
  150. #define INPUT_BRKSIZE (26)
  151. #define INPUT_NUMSIZE (27)
  152. #define INPUT_ALL_WORDS (28)
  153. #define INPUT_WINDOW_SIZE (29)
  154. #define INPUT_MINBRK (30)
  155. #define INPUT_MAXBRK (31)
  156. #define INPUT_MINNUM (32)
  157. #define INPUT_MAXNUM (33)
  158. //TW NEW
  159. #define BUF_MULTIPLIER (20) /* arbitrary size for moment */
  160. /* RWD ARGH - CANNOT declare a var in a header file! I declare in dzsetup.c, so it goes in the library */
  161. /*unsigned int superzargo;*/ /* for timing involving several file-writes */
  162. extern unsigned int superzargo;
  163. #define NUMERICVAL_MARKER '@' /* MUST TALLY WITH TK CODE !! */
  164. void splice_multiline_string(char *str,char *prefix);
  165. #define PBAR_LENGTH (256)
  166. void splice_multiline_string(char *str,char *prefix);
  167. #ifdef IS_UNIX
  168. #define FILE_JOINER '/'
  169. #endif
  170. #ifdef IS_PC
  171. #define FILE_JOINER '\\'
  172. #endif
  173. int redefine_textfile_types(dataptr dz);
  174. int strgetfloat(char **str,double *val);
  175. //TW NEW
  176. int strgetfloat_within_string(char **str,double *val);
  177. void get_other_filename(char *filename,char c);
  178. int close_and_delete_tempfile(char *filename,dataptr dz);
  179. int smpflteq(double f1,double f2);
  180. #define SMP_FLTERR 0.0000005 /* zero (within error) for samprate of 200000 or below */
  181. void insert_new_number_at_filename_end(char *filename,int num,int overwrite_last_char);
  182. void insert_new_chars_at_filename_end(char *filename,char * str);
  183. void replace_filename_extension(char *filename,char *ext);
  184. void delete_filename_lastchar(char *filename);
  185. void reset_file_params_for_sndout(int *orig_proctype,int *orig_srate,
  186. int *orig_chans,int *orig_stype,dataptr dz);
  187. int reset_peak_finder(dataptr dz);
  188. int establish_peak_status(dataptr dz);
  189. #endif
  190. //TW names reflecting new status of these data items
  191. // RWD but SAMP_FLOAT is definiutely a SOUND these days...
  192. #define CDP_SOUND SAMP_SHORT
  193. #define CDP_NONSOUND SAMP_FLOAT
  194. void copy_to_fileptr(infileptr i, fileptr f);