1 /* General functions for signal processing - Header 2 3 * Copyright (C) 1998 J.A. Bezemer 4 * 5 * Licensed under the terms of the GNU General Public License. 6 * ABSOLUTELY NO WARRANTY. 7 * See the file `COPYING' in this directory. 8 */ 9 10 #ifndef HAVE_SIGNPR_GENERAL_H 11 #define HAVE_SIGNPR_GENERAL_H 12 13 #ifndef SWIG 14 #include "scrollmenu.h" 15 #endif 16 17 /* SAMPLES */ 18 19 typedef struct 20 { 21 signed short left; 22 signed short right; 23 } 24 sample_t; 25 26 typedef struct 27 { 28 signed long left; 29 signed long right; 30 } 31 longsample_t; 32 33 typedef struct 34 { 35 double left; 36 double right; 37 } 38 doublesample_t; 39 40 /* This has to be here, otherwise the FFT interpolating filter 41 can't keep its plans [SJT] */ 42 #include <rfftw.h> 43 44 /* BUFFER */ 45 46 typedef struct 47 { 48 sample_t *array; 49 long currpos; 50 long arraylength; 51 long pre_length; /* "read ahead" */ 52 long post_length; /* "remember" */ 53 #ifdef TURBO_BUFFER 54 int *indextable; 55 #endif 56 57 } 58 buffer_t; 59 60 61 /* PARAM */ 62 63 typedef struct 64 { 65 buffer_t buffer; 66 buffer_t buffer2; 67 buffer_t buffer3; 68 buffer_t buffer4; 69 int filterno; /* 'serial number' of filter, 70 0=read_from_disk */ 71 long postlength1, prelength1, postlength2, prelength2, postlength3, 72 prelength3, postlength4, prelength4; 73 signed short *sslist1; 74 signed short *sslist2; 75 76 int int1, int2; 77 long long1; 78 long long2; 79 80 rfftw_plan planf, planr; 81 82 } 83 param_t; 84 85 typedef param_t *parampointer_t; 86 87 88 /* FILTER DATA */ 89 90 #define MAX_FILTERS 50 91 92 extern parampointer_t parampointerarray[MAX_FILTERS]; 93 94 #ifndef SWIG 95 extern int filter_type[MAX_FILTERS]; 96 #endif 97 98 extern int number_of_filters; 99 100 #ifndef SWIG 101 102 /* BASIC SCREEN I/O */ 103 104 void write_sample_to_screen (sample_t data); 105 106 sample_t read_from_keyboard (); 107 108 #endif 109 110 /* BUFFER FILL FUNCTION */ 111 112 typedef sample_t (*fillfuncpointer_t) (long offset, long offset_zero, 113 parampointer_t parampointer); 114 115 116 /* BUFFER FUNCTIONS */ 117 118 buffer_t init_buffer (long post_length, long pre_length); 119 120 void delete_buffer (buffer_t * buffer); 121 122 #ifdef TURBO_BUFFER 123 124 #define get_from_buffer(buffer,offset) (buffer)->array[(buffer)->indextable[(buffer)->currpos+offset]] 125 126 #define put_in_buffer(buffer,offset,sample) (buffer)->array[(buffer)->indextable[(buffer)->currpos+offset]]=sample 127 128 #else /* if not TURBO_BUFFER */ 129 130 sample_t get_from_buffer (buffer_t * buffer, long offset); 131 132 void put_in_buffer (buffer_t * buffer, long offset, sample_t sample); 133 134 #endif /* (not) TURBO_BUFFER */ 135 136 #ifndef SWIG 137 void advance_current_pos (buffer_t * buffer, int filterno); 138 #else 139 void advance_current_pos (buffer_t * buffer, int filterno, int *filter_type); 140 #endif 141 142 void advance_current_pos_custom (buffer_t * buffer, fillfuncpointer_t fillfunc, 143 long offset_zero, parampointer_t parampointer); 144 145 #ifndef SWIG 146 147 /* QUICK SORT */ 148 149 /* One for signed shorts, max size 32676 */ 150 151 void qsort2 (signed short *a, int n); /* a: pointer to start of array */ 152 /* n: # elements in array */ 153 #endif /* SWIG */ 154 /* And one for doubles, max size 2G */ 155 156 void qsort2double (double *a, long n); /* a: pointer to start of array */ 157 /* n: # elements in array */ 158 159 /* MEDIAN */ 160 161 signed short median (signed short *a, int n); 162 163 164 #ifndef SWIG 165 166 /* BUILDING THE LIST OF FILTERS */ 167 168 void add_to_filterlist (scrollmenu_t * filtlist, int *filtnumbers, 169 char **helptexts, int filternumber, char *filtername, 170 char *helptext); 171 172 void make_filterlist (scrollmenu_t * filtlist, int *filtnumbers, 173 char **helptexts); 174 175 176 /* GET SAMPLE FROM FILTER */ 177 178 sample_t get_sample_from_filter (int filterno); 179 180 181 /* INIT & DELETE FILTERS */ 182 183 void init_filters (); 184 185 void delete_filters (); 186 187 #else 188 189 /* GET SAMPLE FROM FILTER */ 190 191 sample_t get_sample_from_filter (int filterno, int *filter_type); 192 193 194 /* INIT & DELETE FILTERS */ 195 196 void init_filters (int number_of_filters, int *filter_type); 197 198 void delete_filters (int *filter_type); 199 200 #endif 201 202 /* PARAM DEFAULTS */ 203 204 void param_defaults (parampointer_t parampointer, int filtertype); 205 206 #ifndef SWIG 207 208 /* PARAM SCREENS */ 209 210 void param_screen (parampointer_t parampointer, int filtertype); 211 212 #endif /* SWIG */ 213 214 /* FILTER NUMBERS ETC. */ 215 216 #define SIMPLE_MEDIAN_FILTER 1 217 #define SIMPLE_MEDIAN_NAME "Simple Median Filter" 218 #define SIMPLE_MEDIAN_HELPTEXT \ 219 "Interpolate short ticks." 220 221 #define SIMPLE_MEAN_FILTER 2 222 #define SIMPLE_MEAN_NAME "Simple Mean Filter" 223 #define SIMPLE_MEAN_HELPTEXT \ 224 "'Smooth' the signal by taking the mean of samples." 225 226 #define COND_MEDIAN_FILTER 3 227 #define COND_MEDIAN_NAME "Conditional Median Filter" 228 #define COND_MEDIAN_HELPTEXT \ 229 "Remove ticks while not changing rest of signal." 230 231 #define DOUBLE_MEDIAN_FILTER 4 232 #define DOUBLE_MEDIAN_NAME "Double Median Filter" 233 #define DOUBLE_MEDIAN_HELPTEXT \ 234 "Interpolate short ticks and correct interpolations." 235 236 #define COND_MEDIAN2_FILTER 5 237 #define COND_MEDIAN2_NAME "Conditional Median Filter II" 238 #define COND_MEDIAN2_HELPTEXT \ 239 "Remove ticks while not changing rest of signal - Better." 240 241 #define RMS_FILTER 6 242 #define RMS_NAME "RMS Filter" 243 #define RMS_HELPTEXT \ 244 "Compute the `running' Root-Mean-Square of the signal." 245 246 #define COPYONLY_FILTER 7 247 #define COPYONLY_NAME "Copy Only" 248 #define COPYONLY_HELPTEXT \ 249 "Do nothing - just copy the signal unchanged." 250 251 #define MONOIZE_FILTER 8 252 #define MONOIZE_NAME "Convert to mono" 253 #define MONOIZE_HELPTEXT \ 254 "Average left & right signals." 255 256 #define COND_MEDIAN3_FILTER 9 257 #define COND_MEDIAN3_NAME "Conditional Median Filter IIF" 258 #define COND_MEDIAN3_HELPTEXT \ 259 "Remove ticks while not changing rest of signal - Using freq domain interp." 260 261 #define EXPERIMENT_FILTER 10 262 #define EXPERIMENT_NAME "Experimenting Filter" 263 #define EXPERIMENT_HELPTEXT \ 264 "The filter YOU are experimenting with (in signpr_exper.c)" 265 266 267 #endif /* HAVE_SIGNPR_GENERAL_H */ 268