diff options
Diffstat (limited to 'apps/codecs/dumb/include/dumb.h')
-rw-r--r-- | apps/codecs/dumb/include/dumb.h | 577 |
1 files changed, 0 insertions, 577 deletions
diff --git a/apps/codecs/dumb/include/dumb.h b/apps/codecs/dumb/include/dumb.h deleted file mode 100644 index 2aae95ccce..0000000000 --- a/apps/codecs/dumb/include/dumb.h +++ /dev/null | |||
@@ -1,577 +0,0 @@ | |||
1 | /* _______ ____ __ ___ ___ | ||
2 | * \ _ \ \ / \ / \ \ / / ' ' ' | ||
3 | * | | \ \ | | || | \/ | . . | ||
4 | * | | | | | | || ||\ /| | | ||
5 | * | | | | | | || || \/ | | ' ' ' | ||
6 | * | | | | | | || || | | . . | ||
7 | * | |_/ / \ \__// || | | | ||
8 | * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque | ||
9 | * / \ | ||
10 | * / . \ | ||
11 | * dumb.h - The user header file for DUMB. / / \ \ | ||
12 | * | < / \_ | ||
13 | * Include this file in any of your files in | \/ /\ / | ||
14 | * which you wish to use the DUMB functions \_ / > / | ||
15 | * and variables. | \ / / | ||
16 | * | ' / | ||
17 | * \__/ | ||
18 | */ | ||
19 | |||
20 | #ifndef DUMB_H | ||
21 | #define DUMB_H | ||
22 | |||
23 | |||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | |||
27 | |||
28 | #ifdef __cplusplus | ||
29 | extern "C" { | ||
30 | #endif | ||
31 | |||
32 | |||
33 | #define DUMB_MAJOR_VERSION 0 | ||
34 | #define DUMB_MINOR_VERSION 9 | ||
35 | #define DUMB_REVISION_VERSION 2 | ||
36 | |||
37 | #define DUMB_VERSION (DUMB_MAJOR_VERSION*10000 + DUMB_MINOR_VERSION*100 + DUMB_REVISION_VERSION) | ||
38 | |||
39 | #define DUMB_VERSION_STR "0.9.2" | ||
40 | |||
41 | #define DUMB_NAME "DUMB v"DUMB_VERSION_STR | ||
42 | |||
43 | #define DUMB_YEAR 2003 | ||
44 | #define DUMB_MONTH 4 | ||
45 | #define DUMB_DAY 2 | ||
46 | |||
47 | #define DUMB_YEAR_STR2 "03" | ||
48 | #define DUMB_YEAR_STR4 "2003" | ||
49 | #define DUMB_MONTH_STR1 "4" | ||
50 | #define DUMB_DAY_STR1 "2" | ||
51 | |||
52 | #if DUMB_MONTH < 10 | ||
53 | #define DUMB_MONTH_STR2 "0"DUMB_MONTH_STR1 | ||
54 | #else | ||
55 | #define DUMB_MONTH_STR2 DUMB_MONTH_STR1 | ||
56 | #endif | ||
57 | |||
58 | #if DUMB_DAY < 10 | ||
59 | #define DUMB_DAY_STR2 "0"DUMB_DAY_STR1 | ||
60 | #else | ||
61 | #define DUMB_DAY_STR2 DUMB_DAY_STR1 | ||
62 | #endif | ||
63 | |||
64 | |||
65 | /* WARNING: The month and day were inadvertently swapped in the v0.8 release. | ||
66 | * Please do not compare this constant against any date in 2002. In | ||
67 | * any case, DUMB_VERSION is probably more useful for this purpose. | ||
68 | */ | ||
69 | #define DUMB_DATE (DUMB_YEAR*10000 + DUMB_MONTH*100 + DUMB_DAY) | ||
70 | |||
71 | #define DUMB_DATE_STR DUMB_DAY_STR1"."DUMB_MONTH_STR1"."DUMB_YEAR_STR4 | ||
72 | |||
73 | |||
74 | #undef MIN | ||
75 | #undef MAX | ||
76 | #undef MID | ||
77 | |||
78 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) | ||
79 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) | ||
80 | #define MID(x,y,z) MAX((x), MIN((y), (z))) | ||
81 | |||
82 | #undef ABS | ||
83 | #define ABS(x) (((x) >= 0) ? (x) : (-(x))) | ||
84 | |||
85 | |||
86 | #if 0 /* This code serves no useful purpose for Rockbox. Possibly the trace | ||
87 | thing could be defined for simulator... */ | ||
88 | |||
89 | #ifdef DEBUGMODE | ||
90 | |||
91 | #ifndef ASSERT | ||
92 | #include <assert.h> | ||
93 | #define ASSERT(n) assert(n) | ||
94 | #endif | ||
95 | #ifndef TRACE | ||
96 | // it would be nice if this did actually trace ... | ||
97 | #define TRACE 1 ? (void)0 : (void)printf | ||
98 | #endif | ||
99 | |||
100 | #else | ||
101 | |||
102 | #ifndef ASSERT | ||
103 | #define ASSERT(n) | ||
104 | #endif | ||
105 | #ifndef TRACE | ||
106 | #define TRACE 1 ? (void)0 : (void)printf | ||
107 | #endif | ||
108 | |||
109 | #endif | ||
110 | |||
111 | #else /* 0 */ | ||
112 | /* disable TRACE() and ASSERT() calls */ | ||
113 | #define TRACE(...) | ||
114 | #define ASSERT(...) | ||
115 | |||
116 | /* now fake float function to hush the compiler */ | ||
117 | #define pow(x,y) ((x)+(y)) | ||
118 | #define floor(x) x | ||
119 | #define log(x) (x) | ||
120 | #define exp(x) (x) | ||
121 | #endif /* 0 */ | ||
122 | |||
123 | #define DUMB_ID(a,b,c,d) (((unsigned int)(a) << 24) | \ | ||
124 | ((unsigned int)(b) << 16) | \ | ||
125 | ((unsigned int)(c) << 8) | \ | ||
126 | ((unsigned int)(d) )) | ||
127 | |||
128 | |||
129 | |||
130 | #ifndef LONG_LONG | ||
131 | #ifdef __GNUC__ | ||
132 | #define LONG_LONG long long | ||
133 | #elif defined _MSC_VER | ||
134 | #define LONG_LONG __int64 | ||
135 | #else | ||
136 | #error 64-bit integer type unknown | ||
137 | #endif | ||
138 | #endif | ||
139 | |||
140 | #if __GNUC__ * 100 + __GNUC_MINOR__ >= 301 /* GCC 3.1+ */ | ||
141 | #ifndef DUMB_DECLARE_DEPRECATED | ||
142 | #define DUMB_DECLARE_DEPRECATED | ||
143 | #endif | ||
144 | #define DUMB_DEPRECATED __attribute__((__deprecated__)) | ||
145 | #else | ||
146 | #define DUMB_DEPRECATED | ||
147 | #endif | ||
148 | |||
149 | |||
150 | /* Basic Sample Type. Normal range is -0x800000 to 0x7FFFFF. */ | ||
151 | |||
152 | typedef int sample_t; | ||
153 | |||
154 | |||
155 | /* Library Clean-up Management */ | ||
156 | |||
157 | int dumb_atexit(void (*proc)(void)); | ||
158 | |||
159 | void dumb_exit(void); | ||
160 | |||
161 | |||
162 | /* File Input Functions */ | ||
163 | |||
164 | typedef struct DUMBFILE_SYSTEM | ||
165 | { | ||
166 | void *(*open)(const char *filename); | ||
167 | int (*skip)(void *f, long n); | ||
168 | int (*getc)(void *f); | ||
169 | long (*getnc)(char *ptr, long n, void *f); | ||
170 | void (*close)(void *f); | ||
171 | } | ||
172 | DUMBFILE_SYSTEM; | ||
173 | |||
174 | typedef struct DUMBFILE DUMBFILE; | ||
175 | |||
176 | void register_dumbfile_system(DUMBFILE_SYSTEM *dfs); | ||
177 | |||
178 | DUMBFILE *dumbfile_open(const char *filename); | ||
179 | DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs); | ||
180 | |||
181 | long dumbfile_pos(DUMBFILE *f); | ||
182 | int dumbfile_skip(DUMBFILE *f, long n); | ||
183 | |||
184 | int dumbfile_getc(DUMBFILE *f); | ||
185 | |||
186 | int dumbfile_igetw(DUMBFILE *f); | ||
187 | int dumbfile_mgetw(DUMBFILE *f); | ||
188 | |||
189 | long dumbfile_igetl(DUMBFILE *f); | ||
190 | long dumbfile_mgetl(DUMBFILE *f); | ||
191 | |||
192 | unsigned long dumbfile_cgetul(DUMBFILE *f); | ||
193 | signed long dumbfile_cgetsl(DUMBFILE *f); | ||
194 | |||
195 | long dumbfile_getnc(char *ptr, long n, DUMBFILE *f); | ||
196 | |||
197 | int dumbfile_error(DUMBFILE *f); | ||
198 | int dumbfile_close(DUMBFILE *f); | ||
199 | |||
200 | |||
201 | /* stdio File Input Module */ | ||
202 | |||
203 | /*void dumb_register_stdfiles(void); | ||
204 | |||
205 | DUMBFILE *dumbfile_open_stdfile(int fd);*/ | ||
206 | |||
207 | |||
208 | /* Memory File Input Module */ | ||
209 | |||
210 | DUMBFILE *dumbfile_open_memory(const char *data, long size); | ||
211 | |||
212 | |||
213 | /* DUH Management */ | ||
214 | |||
215 | typedef struct DUH DUH; | ||
216 | |||
217 | #define DUH_SIGNATURE DUMB_ID('D','U','H','!') | ||
218 | |||
219 | void unload_duh(DUH *duh); | ||
220 | |||
221 | DUH *load_duh(const char *filename); | ||
222 | DUH *read_duh(DUMBFILE *f); | ||
223 | |||
224 | long duh_get_length(DUH *duh); | ||
225 | |||
226 | |||
227 | /* Signal Rendering Functions */ | ||
228 | |||
229 | typedef struct DUH_SIGRENDERER DUH_SIGRENDERER; | ||
230 | |||
231 | DUH_SIGRENDERER *duh_start_sigrenderer(DUH *duh, int sig, int n_channels, long pos); | ||
232 | |||
233 | #ifdef DUMB_DECLARE_DEPRECATED | ||
234 | typedef void (*DUH_SIGRENDERER_CALLBACK)(void *data, sample_t **samples, int n_channels, long length); | ||
235 | /* This is deprecated, but is not marked as such because GCC tends to | ||
236 | * complain spuriously when the typedef is used later. See comments below. | ||
237 | */ | ||
238 | |||
239 | void duh_sigrenderer_set_callback( | ||
240 | DUH_SIGRENDERER *sigrenderer, | ||
241 | DUH_SIGRENDERER_CALLBACK callback, void *data | ||
242 | ) DUMB_DEPRECATED; | ||
243 | /* The 'callback' argument's type has changed for const-correctness. See the | ||
244 | * DUH_SIGRENDERER_CALLBACK definition just above. Also note that the samples | ||
245 | * in the buffer are now 256 times as large; the normal range is -0x800000 to | ||
246 | * 0x7FFFFF. The function has been renamed partly because its functionality | ||
247 | * has changed slightly and partly so that its name is more meaningful. The | ||
248 | * new one is duh_sigrenderer_set_analyser_callback(), and the typedef for | ||
249 | * the function pointer has also changed, from DUH_SIGRENDERER_CALLBACK to | ||
250 | * DUH_SIGRENDERER_ANALYSER_CALLBACK. (If you wanted to use this callback to | ||
251 | * apply a DSP effect, don't worry; there is a better way of doing this. It | ||
252 | * is undocumented, so contact me and I shall try to help. Contact details | ||
253 | * are in readme.txt.) | ||
254 | */ | ||
255 | #endif | ||
256 | |||
257 | typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data, const sample_t *const *samples, int n_channels, long length); | ||
258 | |||
259 | void duh_sigrenderer_set_analyser_callback( | ||
260 | DUH_SIGRENDERER *sigrenderer, | ||
261 | DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data | ||
262 | ); | ||
263 | |||
264 | int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer); | ||
265 | long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer); | ||
266 | |||
267 | void duh_sigrenderer_set_sigparam(DUH_SIGRENDERER *sigrenderer, unsigned char id, long value); | ||
268 | |||
269 | long duh_sigrenderer_get_samples( | ||
270 | DUH_SIGRENDERER *sigrenderer, | ||
271 | float volume, float delta, | ||
272 | long size, sample_t **samples | ||
273 | ); | ||
274 | |||
275 | void duh_sigrenderer_get_current_sample(DUH_SIGRENDERER *sigrenderer, float volume, sample_t *samples); | ||
276 | |||
277 | void duh_end_sigrenderer(DUH_SIGRENDERER *sigrenderer); | ||
278 | |||
279 | |||
280 | /* DUH Rendering Functions */ | ||
281 | |||
282 | long duh_render( | ||
283 | DUH_SIGRENDERER *sigrenderer, | ||
284 | int bits, int unsign, | ||
285 | float volume, float delta, | ||
286 | long size, void *sptr | ||
287 | ); | ||
288 | |||
289 | #ifdef DUMB_DECLARE_DEPRECATED | ||
290 | |||
291 | long duh_render_signal( | ||
292 | DUH_SIGRENDERER *sigrenderer, | ||
293 | float volume, float delta, | ||
294 | long size, sample_t **samples | ||
295 | ) DUMB_DEPRECATED; | ||
296 | /* Please use duh_sigrenderer_get_samples(). Arguments and functionality are | ||
297 | * identical. | ||
298 | */ | ||
299 | |||
300 | typedef DUH_SIGRENDERER DUH_RENDERER DUMB_DEPRECATED; | ||
301 | /* Please use DUH_SIGRENDERER instead of DUH_RENDERER. */ | ||
302 | |||
303 | DUH_SIGRENDERER *duh_start_renderer(DUH *duh, int n_channels, long pos) DUMB_DEPRECATED; | ||
304 | /* Please use duh_start_sigrenderer() instead. Pass 0 for 'sig'. */ | ||
305 | |||
306 | int duh_renderer_get_n_channels(DUH_SIGRENDERER *dr) DUMB_DEPRECATED; | ||
307 | long duh_renderer_get_position(DUH_SIGRENDERER *dr) DUMB_DEPRECATED; | ||
308 | /* Please use the duh_sigrenderer_*() equivalents of these two functions. */ | ||
309 | |||
310 | void duh_end_renderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED; | ||
311 | /* Please use duh_end_sigrenderer() instead. */ | ||
312 | |||
313 | DUH_SIGRENDERER *duh_renderer_encapsulate_sigrenderer(DUH_SIGRENDERER *sigrenderer) DUMB_DEPRECATED; | ||
314 | DUH_SIGRENDERER *duh_renderer_get_sigrenderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED; | ||
315 | DUH_SIGRENDERER *duh_renderer_decompose_to_sigrenderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED; | ||
316 | /* These functions have become no-ops that just return the parameter. | ||
317 | * So, for instance, replace | ||
318 | * duh_renderer_encapsulate_sigrenderer(my_sigrenderer) | ||
319 | * with | ||
320 | * my_sigrenderer | ||
321 | */ | ||
322 | |||
323 | #endif | ||
324 | |||
325 | |||
326 | /* Impulse Tracker Support */ | ||
327 | |||
328 | extern int dumb_it_max_to_mix; | ||
329 | |||
330 | typedef struct DUMB_IT_SIGDATA DUMB_IT_SIGDATA; | ||
331 | typedef struct DUMB_IT_SIGRENDERER DUMB_IT_SIGRENDERER; | ||
332 | |||
333 | DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh); | ||
334 | DUH_SIGRENDERER *duh_encapsulate_it_sigrenderer(DUMB_IT_SIGRENDERER *it_sigrenderer, int n_channels, long pos); | ||
335 | DUMB_IT_SIGRENDERER *duh_get_it_sigrenderer(DUH_SIGRENDERER *sigrenderer); | ||
336 | |||
337 | DUH_SIGRENDERER *dumb_it_start_at_order(DUH *duh, int n_channels, int startorder); | ||
338 | |||
339 | void dumb_it_set_loop_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data), void *data); | ||
340 | void dumb_it_set_xm_speed_zero_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data), void *data); | ||
341 | void dumb_it_set_midi_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data, int channel, unsigned char byte), void *data); | ||
342 | |||
343 | int dumb_it_callback_terminate(void *data); | ||
344 | int dumb_it_callback_midi_block(void *data, int channel, unsigned char byte); | ||
345 | |||
346 | DUH *dumb_load_it(const char *filename); | ||
347 | DUH *dumb_load_xm(const char *filename); | ||
348 | DUH *dumb_load_s3m(const char *filename); | ||
349 | DUH *dumb_load_mod(const char *filename); | ||
350 | |||
351 | DUH *dumb_read_it(DUMBFILE *f); | ||
352 | DUH *dumb_read_xm(DUMBFILE *f); | ||
353 | DUH *dumb_read_s3m(DUMBFILE *f); | ||
354 | DUH *dumb_read_mod(DUMBFILE *f); | ||
355 | |||
356 | int dumb_it_sd_get_n_orders(DUMB_IT_SIGDATA *sd); | ||
357 | |||
358 | int dumb_it_sd_get_initial_global_volume(DUMB_IT_SIGDATA *sd); | ||
359 | void dumb_it_sd_set_initial_global_volume(DUMB_IT_SIGDATA *sd, int gv); | ||
360 | |||
361 | int dumb_it_sd_get_mixing_volume(DUMB_IT_SIGDATA *sd); | ||
362 | void dumb_it_sd_set_mixing_volume(DUMB_IT_SIGDATA *sd, int mv); | ||
363 | |||
364 | int dumb_it_sd_get_initial_speed(DUMB_IT_SIGDATA *sd); | ||
365 | void dumb_it_sd_set_initial_speed(DUMB_IT_SIGDATA *sd, int speed); | ||
366 | |||
367 | int dumb_it_sd_get_initial_tempo(DUMB_IT_SIGDATA *sd); | ||
368 | void dumb_it_sd_set_initial_tempo(DUMB_IT_SIGDATA *sd, int tempo); | ||
369 | |||
370 | int dumb_it_sd_get_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel); | ||
371 | void dumb_it_sd_set_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel, int volume); | ||
372 | |||
373 | int dumb_it_sr_get_current_order(DUMB_IT_SIGRENDERER *sr); | ||
374 | int dumb_it_sr_get_current_row(DUMB_IT_SIGRENDERER *sr); | ||
375 | |||
376 | int dumb_it_sr_get_global_volume(DUMB_IT_SIGRENDERER *sr); | ||
377 | void dumb_it_sr_set_global_volume(DUMB_IT_SIGRENDERER *sr, int gv); | ||
378 | |||
379 | int dumb_it_sr_get_tempo(DUMB_IT_SIGRENDERER *sr); | ||
380 | void dumb_it_sr_set_tempo(DUMB_IT_SIGRENDERER *sr, int tempo); | ||
381 | |||
382 | int dumb_it_sr_get_speed(DUMB_IT_SIGRENDERER *sr); | ||
383 | void dumb_it_sr_set_speed(DUMB_IT_SIGRENDERER *sr, int speed); | ||
384 | |||
385 | #define DUMB_IT_N_CHANNELS 64 | ||
386 | #define DUMB_IT_N_NNA_CHANNELS 192 | ||
387 | #define DUMB_IT_TOTAL_CHANNELS (DUMB_IT_N_CHANNELS + DUMB_IT_N_NNA_CHANNELS) | ||
388 | |||
389 | /* Channels passed to any of these functions are 0-based */ | ||
390 | int dumb_it_sr_get_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel); | ||
391 | void dumb_it_sr_set_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel, int volume); | ||
392 | |||
393 | typedef struct DUMB_IT_CHANNEL_STATE DUMB_IT_CHANNEL_STATE; | ||
394 | |||
395 | struct DUMB_IT_CHANNEL_STATE | ||
396 | { | ||
397 | int channel; /* 0-based; meaningful for NNA channels */ | ||
398 | int sample; /* 1-based; 0 if nothing playing, then other fields undef */ | ||
399 | int freq; /* in Hz */ | ||
400 | float volume; /* 1.0 maximum; affected by ALL factors, inc. mixing vol */ | ||
401 | unsigned char pan; /* 0-64, 100 for surround */ | ||
402 | signed char subpan; /* use (pan + subpan/256.0f) or ((pan<<8)+subpan) */ | ||
403 | unsigned char filter_cutoff; /* 0-127 cutoff=127 AND resonance=0 */ | ||
404 | unsigned char filter_subcutoff; /* 0-255 -> no filters (subcutoff */ | ||
405 | unsigned char filter_resonance; /* 0-127 always 0 in this case) */ | ||
406 | /* subcutoff only changes from zero if filter envelopes are in use. The | ||
407 | * calculation (filter_cutoff + filter_subcutoff/256.0f) gives a more | ||
408 | * accurate filter cutoff measurement as a float. It would often be more | ||
409 | * useful to use a scaled int such as ((cutoff<<8) + subcutoff). | ||
410 | */ | ||
411 | }; | ||
412 | |||
413 | /* Values of 64 or more will access NNA channels here. */ | ||
414 | void dumb_it_sr_get_channel_state(DUMB_IT_SIGRENDERER *sr, int channel, DUMB_IT_CHANNEL_STATE *state); | ||
415 | |||
416 | |||
417 | /* Signal Design Helper Values */ | ||
418 | |||
419 | /* Use pow(DUMB_SEMITONE_BASE, n) to get the 'delta' value to transpose up by | ||
420 | * n semitones. To transpose down, use negative n. | ||
421 | */ | ||
422 | #define DUMB_SEMITONE_BASE 1.059463094359295309843105314939748495817 | ||
423 | |||
424 | /* Use pow(DUMB_QUARTERTONE_BASE, n) to get the 'delta' value to transpose up | ||
425 | * by n quartertones. To transpose down, use negative n. | ||
426 | */ | ||
427 | #define DUMB_QUARTERTONE_BASE 1.029302236643492074463779317738953977823 | ||
428 | |||
429 | /* Use pow(DUMB_PITCH_BASE, n) to get the 'delta' value to transpose up by n | ||
430 | * units. In this case, 256 units represent one semitone; 3072 units | ||
431 | * represent one octave. These units are used by the sequence signal (SEQU). | ||
432 | */ | ||
433 | #define DUMB_PITCH_BASE 1.000225659305069791926712241547647863626 | ||
434 | |||
435 | |||
436 | /* Signal Design Function Types */ | ||
437 | |||
438 | typedef void sigdata_t; | ||
439 | typedef void sigrenderer_t; | ||
440 | |||
441 | typedef sigdata_t *(*DUH_LOAD_SIGDATA)(DUH *duh, DUMBFILE *file); | ||
442 | |||
443 | typedef sigrenderer_t *(*DUH_START_SIGRENDERER)( | ||
444 | DUH *duh, | ||
445 | sigdata_t *sigdata, | ||
446 | int n_channels, | ||
447 | long pos | ||
448 | ); | ||
449 | |||
450 | typedef void (*DUH_SIGRENDERER_SET_SIGPARAM)( | ||
451 | sigrenderer_t *sigrenderer, | ||
452 | unsigned char id, long value | ||
453 | ); | ||
454 | |||
455 | typedef long (*DUH_SIGRENDERER_GET_SAMPLES)( | ||
456 | sigrenderer_t *sigrenderer, | ||
457 | float volume, float delta, | ||
458 | long size, sample_t **samples | ||
459 | ); | ||
460 | |||
461 | typedef void (*DUH_SIGRENDERER_GET_CURRENT_SAMPLE)( | ||
462 | sigrenderer_t *sigrenderer, | ||
463 | float volume, | ||
464 | sample_t *samples | ||
465 | ); | ||
466 | |||
467 | typedef void (*DUH_END_SIGRENDERER)(sigrenderer_t *sigrenderer); | ||
468 | |||
469 | typedef void (*DUH_UNLOAD_SIGDATA)(sigdata_t *sigdata); | ||
470 | |||
471 | |||
472 | /* Signal Design Function Registration */ | ||
473 | |||
474 | typedef struct DUH_SIGTYPE_DESC | ||
475 | { | ||
476 | long type; | ||
477 | DUH_LOAD_SIGDATA load_sigdata; | ||
478 | DUH_START_SIGRENDERER start_sigrenderer; | ||
479 | DUH_SIGRENDERER_SET_SIGPARAM sigrenderer_set_sigparam; | ||
480 | DUH_SIGRENDERER_GET_SAMPLES sigrenderer_get_samples; | ||
481 | DUH_SIGRENDERER_GET_CURRENT_SAMPLE sigrenderer_get_current_sample; | ||
482 | DUH_END_SIGRENDERER end_sigrenderer; | ||
483 | DUH_UNLOAD_SIGDATA unload_sigdata; | ||
484 | } | ||
485 | DUH_SIGTYPE_DESC; | ||
486 | |||
487 | void dumb_register_sigtype(DUH_SIGTYPE_DESC *desc); | ||
488 | |||
489 | |||
490 | // Decide where to put these functions; new heading? | ||
491 | |||
492 | sigdata_t *duh_get_raw_sigdata(DUH *duh, int sig, long type); | ||
493 | |||
494 | DUH_SIGRENDERER *duh_encapsulate_raw_sigrenderer(sigrenderer_t *vsigrenderer, DUH_SIGTYPE_DESC *desc, int n_channels, long pos); | ||
495 | sigrenderer_t *duh_get_raw_sigrenderer(DUH_SIGRENDERER *sigrenderer, long type); | ||
496 | |||
497 | |||
498 | /* Sample Buffer Allocation Helpers */ | ||
499 | |||
500 | sample_t **create_sample_buffer(int n_channels, long length); | ||
501 | void destroy_sample_buffer(sample_t **samples); | ||
502 | |||
503 | |||
504 | /* Silencing Helper */ | ||
505 | |||
506 | void dumb_silence(sample_t *samples, long length); | ||
507 | |||
508 | |||
509 | /* Click Removal Helpers */ | ||
510 | |||
511 | typedef struct DUMB_CLICK_REMOVER DUMB_CLICK_REMOVER; | ||
512 | |||
513 | DUMB_CLICK_REMOVER *dumb_create_click_remover(void); | ||
514 | void dumb_record_click(DUMB_CLICK_REMOVER *cr, long pos, sample_t step); | ||
515 | void dumb_remove_clicks(DUMB_CLICK_REMOVER *cr, sample_t *samples, long length, float halflife); | ||
516 | sample_t dumb_click_remover_get_offset(DUMB_CLICK_REMOVER *cr); | ||
517 | void dumb_destroy_click_remover(DUMB_CLICK_REMOVER *cr); | ||
518 | |||
519 | DUMB_CLICK_REMOVER **dumb_create_click_remover_array(int n); | ||
520 | void dumb_record_click_array(int n, DUMB_CLICK_REMOVER **cr, long pos, sample_t *step); | ||
521 | void dumb_record_click_negative_array(int n, DUMB_CLICK_REMOVER **cr, long pos, sample_t *step); | ||
522 | void dumb_remove_clicks_array(int n, DUMB_CLICK_REMOVER **cr, sample_t **samples, long length, float halflife); | ||
523 | void dumb_click_remover_get_offset_array(int n, DUMB_CLICK_REMOVER **cr, sample_t *offset); | ||
524 | void dumb_destroy_click_remover_array(int n, DUMB_CLICK_REMOVER **cr); | ||
525 | |||
526 | |||
527 | /* Resampling Helpers */ | ||
528 | |||
529 | #define DUMB_RQ_ALIASING 0 | ||
530 | #define DUMB_RQ_LINEAR 1 | ||
531 | #define DUMB_RQ_CUBIC 2 | ||
532 | #define DUMB_RQ_N_LEVELS 3 | ||
533 | extern int dumb_resampling_quality; | ||
534 | |||
535 | typedef struct DUMB_RESAMPLER DUMB_RESAMPLER; | ||
536 | |||
537 | typedef void (*DUMB_RESAMPLE_PICKUP)(DUMB_RESAMPLER *resampler, void *data); | ||
538 | |||
539 | struct DUMB_RESAMPLER | ||
540 | { | ||
541 | sample_t *src; | ||
542 | long pos; | ||
543 | int subpos; | ||
544 | long start, end; | ||
545 | int dir; | ||
546 | DUMB_RESAMPLE_PICKUP pickup; | ||
547 | void *pickup_data; | ||
548 | int min_quality; | ||
549 | int max_quality; | ||
550 | /* Everything below this point is internal: do not use. */ | ||
551 | sample_t x[3]; | ||
552 | int overshot; | ||
553 | }; | ||
554 | |||
555 | void dumb_reset_resampler(DUMB_RESAMPLER *resampler, sample_t *src, long pos, long start, long end); | ||
556 | DUMB_RESAMPLER *dumb_start_resampler(sample_t *src, long pos, long start, long end); | ||
557 | long dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, long dst_size, float volume, float delta); | ||
558 | sample_t dumb_resample_get_current_sample(DUMB_RESAMPLER *resampler, float volume); | ||
559 | void dumb_end_resampler(DUMB_RESAMPLER *resampler); | ||
560 | |||
561 | |||
562 | /* DUH Construction */ | ||
563 | |||
564 | DUH *make_duh( | ||
565 | long length, | ||
566 | int n_signals, | ||
567 | DUH_SIGTYPE_DESC *desc[], | ||
568 | sigdata_t *sigdata[] | ||
569 | ); | ||
570 | |||
571 | |||
572 | #ifdef __cplusplus | ||
573 | } | ||
574 | #endif | ||
575 | |||
576 | |||
577 | #endif /* DUMB_H */ | ||