summaryrefslogtreecommitdiff
path: root/apps/codecs/dumb/include
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/dumb/include')
-rw-r--r--apps/codecs/dumb/include/aldumb.h93
-rw-r--r--apps/codecs/dumb/include/dumb.h563
-rw-r--r--apps/codecs/dumb/include/internal/aldumb.h27
-rw-r--r--apps/codecs/dumb/include/internal/dumb.h58
-rw-r--r--apps/codecs/dumb/include/internal/it.h710
5 files changed, 1451 insertions, 0 deletions
diff --git a/apps/codecs/dumb/include/aldumb.h b/apps/codecs/dumb/include/aldumb.h
new file mode 100644
index 0000000000..dae2029316
--- /dev/null
+++ b/apps/codecs/dumb/include/aldumb.h
@@ -0,0 +1,93 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * aldumb.h - The user header file for DUMB with / / \ \
12 * Allegro. | < / \_
13 * | \/ /\ /
14 * Include this file if you wish to use DUMB \_ / > /
15 * with Allegro. It will include dumb.h for you, | \ / /
16 * and provide extra functionality such as audio | ' /
17 * stream and datafile integration. \__/
18 */
19
20#ifndef ALDUMB_H
21#define ALDUMB_H
22
23
24#include <allegro.h>
25
26#include "dumb.h"
27
28
29#ifdef __cplusplus
30 extern "C" {
31#endif
32
33
34/* Packfile Support */
35
36void dumb_register_packfiles(void);
37
38DUMBFILE *dumbfile_open_packfile(PACKFILE *p);
39DUMBFILE *dumbfile_from_packfile(PACKFILE *p);
40
41
42/* Datafile Registration Functions */
43
44#define DUMB_DAT_DUH DAT_ID('D','U','H',' ')
45#define DUMB_DAT_IT DAT_ID('I','T',' ',' ')
46#define DUMB_DAT_XM DAT_ID('X','M',' ',' ')
47#define DUMB_DAT_S3M DAT_ID('S','3','M',' ')
48#define DUMB_DAT_MOD DAT_ID('M','O','D',' ')
49
50void dumb_register_dat_duh(long type);
51void dumb_register_dat_it(long type);
52void dumb_register_dat_xm(long type);
53void dumb_register_dat_s3m(long type);
54void dumb_register_dat_mod(long type);
55
56
57/* DUH Playing Functions */
58
59typedef struct AL_DUH_PLAYER AL_DUH_PLAYER;
60
61AL_DUH_PLAYER *al_start_duh(DUH *duh, int n_channels, long pos, float volume, long bufsize, int freq);
62void al_stop_duh(AL_DUH_PLAYER *dp);
63void al_pause_duh(AL_DUH_PLAYER *dp);
64void al_resume_duh(AL_DUH_PLAYER *dp);
65void al_duh_set_priority(AL_DUH_PLAYER *dp, int priority);
66void al_duh_set_volume(AL_DUH_PLAYER *dp, float volume);
67int al_poll_duh(AL_DUH_PLAYER *dp);
68long al_duh_get_position(AL_DUH_PLAYER *dp);
69
70AL_DUH_PLAYER *al_duh_encapsulate_sigrenderer(DUH_SIGRENDERER *sigrenderer, float volume, long bufsize, int freq);
71DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp);
72
73/* IMPORTANT: This function will return NULL if the music has ended. */
74DUH_SIGRENDERER *al_duh_decompose_to_sigrenderer(AL_DUH_PLAYER *dp);
75
76#ifdef DUMB_DECLARE_DEPRECATED
77
78AL_DUH_PLAYER *al_duh_encapsulate_renderer(DUH_SIGRENDERER *dr, float volume, long bufsize, int freq) DUMB_DEPRECATED;
79DUH_SIGRENDERER *al_duh_get_renderer(AL_DUH_PLAYER *dp) DUMB_DEPRECATED;
80DUH_SIGRENDERER *al_duh_decompose_to_renderer(AL_DUH_PLAYER *dp) DUMB_DEPRECATED;
81/* Replace 'renderer' with 'sigrenderer' in each case where you called one of
82 * these functions.
83 */
84
85#endif
86
87
88#ifdef __cplusplus
89 }
90#endif
91
92
93#endif /* ALDUMB_H */
diff --git a/apps/codecs/dumb/include/dumb.h b/apps/codecs/dumb/include/dumb.h
new file mode 100644
index 0000000000..3d6d6f940d
--- /dev/null
+++ b/apps/codecs/dumb/include/dumb.h
@@ -0,0 +1,563 @@
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#ifdef DEBUGMODE
87
88#ifndef ASSERT
89#include <assert.h>
90#define ASSERT(n) assert(n)
91#endif
92#ifndef TRACE
93// it would be nice if this did actually trace ...
94#define TRACE 1 ? (void)0 : (void)printf
95#endif
96
97#else
98
99#ifndef ASSERT
100#define ASSERT(n)
101#endif
102#ifndef TRACE
103#define TRACE 1 ? (void)0 : (void)printf
104#endif
105
106#endif
107
108
109#define DUMB_ID(a,b,c,d) (((unsigned int)(a) << 24) | \
110 ((unsigned int)(b) << 16) | \
111 ((unsigned int)(c) << 8) | \
112 ((unsigned int)(d) ))
113
114
115
116#ifndef LONG_LONG
117#ifdef __GNUC__
118#define LONG_LONG long long
119#elif defined _MSC_VER
120#define LONG_LONG __int64
121#else
122#error 64-bit integer type unknown
123#endif
124#endif
125
126#if __GNUC__ * 100 + __GNUC_MINOR__ >= 301 /* GCC 3.1+ */
127#ifndef DUMB_DECLARE_DEPRECATED
128#define DUMB_DECLARE_DEPRECATED
129#endif
130#define DUMB_DEPRECATED __attribute__((__deprecated__))
131#else
132#define DUMB_DEPRECATED
133#endif
134
135
136/* Basic Sample Type. Normal range is -0x800000 to 0x7FFFFF. */
137
138typedef int sample_t;
139
140
141/* Library Clean-up Management */
142
143int dumb_atexit(void (*proc)(void));
144
145void dumb_exit(void);
146
147
148/* File Input Functions */
149
150typedef struct DUMBFILE_SYSTEM
151{
152 void *(*open)(const char *filename);
153 int (*skip)(void *f, long n);
154 int (*getc)(void *f);
155 long (*getnc)(char *ptr, long n, void *f);
156 void (*close)(void *f);
157}
158DUMBFILE_SYSTEM;
159
160typedef struct DUMBFILE DUMBFILE;
161
162void register_dumbfile_system(DUMBFILE_SYSTEM *dfs);
163
164DUMBFILE *dumbfile_open(const char *filename);
165DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs);
166
167long dumbfile_pos(DUMBFILE *f);
168int dumbfile_skip(DUMBFILE *f, long n);
169
170int dumbfile_getc(DUMBFILE *f);
171
172int dumbfile_igetw(DUMBFILE *f);
173int dumbfile_mgetw(DUMBFILE *f);
174
175long dumbfile_igetl(DUMBFILE *f);
176long dumbfile_mgetl(DUMBFILE *f);
177
178unsigned long dumbfile_cgetul(DUMBFILE *f);
179signed long dumbfile_cgetsl(DUMBFILE *f);
180
181long dumbfile_getnc(char *ptr, long n, DUMBFILE *f);
182
183int dumbfile_error(DUMBFILE *f);
184int dumbfile_close(DUMBFILE *f);
185
186
187/* stdio File Input Module */
188
189/*void dumb_register_stdfiles(void);
190
191DUMBFILE *dumbfile_open_stdfile(int fd);*/
192
193
194/* Memory File Input Module */
195
196DUMBFILE *dumbfile_open_memory(const char *data, long size);
197
198
199/* DUH Management */
200
201typedef struct DUH DUH;
202
203#define DUH_SIGNATURE DUMB_ID('D','U','H','!')
204
205void unload_duh(DUH *duh);
206
207DUH *load_duh(const char *filename);
208DUH *read_duh(DUMBFILE *f);
209
210long duh_get_length(DUH *duh);
211
212
213/* Signal Rendering Functions */
214
215typedef struct DUH_SIGRENDERER DUH_SIGRENDERER;
216
217DUH_SIGRENDERER *duh_start_sigrenderer(DUH *duh, int sig, int n_channels, long pos);
218
219#ifdef DUMB_DECLARE_DEPRECATED
220typedef void (*DUH_SIGRENDERER_CALLBACK)(void *data, sample_t **samples, int n_channels, long length);
221/* This is deprecated, but is not marked as such because GCC tends to
222 * complain spuriously when the typedef is used later. See comments below.
223 */
224
225void duh_sigrenderer_set_callback(
226 DUH_SIGRENDERER *sigrenderer,
227 DUH_SIGRENDERER_CALLBACK callback, void *data
228) DUMB_DEPRECATED;
229/* The 'callback' argument's type has changed for const-correctness. See the
230 * DUH_SIGRENDERER_CALLBACK definition just above. Also note that the samples
231 * in the buffer are now 256 times as large; the normal range is -0x800000 to
232 * 0x7FFFFF. The function has been renamed partly because its functionality
233 * has changed slightly and partly so that its name is more meaningful. The
234 * new one is duh_sigrenderer_set_analyser_callback(), and the typedef for
235 * the function pointer has also changed, from DUH_SIGRENDERER_CALLBACK to
236 * DUH_SIGRENDERER_ANALYSER_CALLBACK. (If you wanted to use this callback to
237 * apply a DSP effect, don't worry; there is a better way of doing this. It
238 * is undocumented, so contact me and I shall try to help. Contact details
239 * are in readme.txt.)
240 */
241#endif
242
243typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data, const sample_t *const *samples, int n_channels, long length);
244
245void duh_sigrenderer_set_analyser_callback(
246 DUH_SIGRENDERER *sigrenderer,
247 DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data
248);
249
250int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer);
251long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer);
252
253void duh_sigrenderer_set_sigparam(DUH_SIGRENDERER *sigrenderer, unsigned char id, long value);
254
255long duh_sigrenderer_get_samples(
256 DUH_SIGRENDERER *sigrenderer,
257 float volume, float delta,
258 long size, sample_t **samples
259);
260
261void duh_sigrenderer_get_current_sample(DUH_SIGRENDERER *sigrenderer, float volume, sample_t *samples);
262
263void duh_end_sigrenderer(DUH_SIGRENDERER *sigrenderer);
264
265
266/* DUH Rendering Functions */
267
268long duh_render(
269 DUH_SIGRENDERER *sigrenderer,
270 int bits, int unsign,
271 float volume, float delta,
272 long size, void *sptr
273);
274
275#ifdef DUMB_DECLARE_DEPRECATED
276
277long duh_render_signal(
278 DUH_SIGRENDERER *sigrenderer,
279 float volume, float delta,
280 long size, sample_t **samples
281) DUMB_DEPRECATED;
282/* Please use duh_sigrenderer_get_samples(). Arguments and functionality are
283 * identical.
284 */
285
286typedef DUH_SIGRENDERER DUH_RENDERER DUMB_DEPRECATED;
287/* Please use DUH_SIGRENDERER instead of DUH_RENDERER. */
288
289DUH_SIGRENDERER *duh_start_renderer(DUH *duh, int n_channels, long pos) DUMB_DEPRECATED;
290/* Please use duh_start_sigrenderer() instead. Pass 0 for 'sig'. */
291
292int duh_renderer_get_n_channels(DUH_SIGRENDERER *dr) DUMB_DEPRECATED;
293long duh_renderer_get_position(DUH_SIGRENDERER *dr) DUMB_DEPRECATED;
294/* Please use the duh_sigrenderer_*() equivalents of these two functions. */
295
296void duh_end_renderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED;
297/* Please use duh_end_sigrenderer() instead. */
298
299DUH_SIGRENDERER *duh_renderer_encapsulate_sigrenderer(DUH_SIGRENDERER *sigrenderer) DUMB_DEPRECATED;
300DUH_SIGRENDERER *duh_renderer_get_sigrenderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED;
301DUH_SIGRENDERER *duh_renderer_decompose_to_sigrenderer(DUH_SIGRENDERER *dr) DUMB_DEPRECATED;
302/* These functions have become no-ops that just return the parameter.
303 * So, for instance, replace
304 * duh_renderer_encapsulate_sigrenderer(my_sigrenderer)
305 * with
306 * my_sigrenderer
307 */
308
309#endif
310
311
312/* Impulse Tracker Support */
313
314extern int dumb_it_max_to_mix;
315
316typedef struct DUMB_IT_SIGDATA DUMB_IT_SIGDATA;
317typedef struct DUMB_IT_SIGRENDERER DUMB_IT_SIGRENDERER;
318
319DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh);
320DUH_SIGRENDERER *duh_encapsulate_it_sigrenderer(DUMB_IT_SIGRENDERER *it_sigrenderer, int n_channels, long pos);
321DUMB_IT_SIGRENDERER *duh_get_it_sigrenderer(DUH_SIGRENDERER *sigrenderer);
322
323DUH_SIGRENDERER *dumb_it_start_at_order(DUH *duh, int n_channels, int startorder);
324
325void dumb_it_set_loop_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data), void *data);
326void dumb_it_set_xm_speed_zero_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data), void *data);
327void dumb_it_set_midi_callback(DUMB_IT_SIGRENDERER *sigrenderer, int (*callback)(void *data, int channel, unsigned char byte), void *data);
328
329int dumb_it_callback_terminate(void *data);
330int dumb_it_callback_midi_block(void *data, int channel, unsigned char byte);
331
332DUH *dumb_load_it(const char *filename);
333DUH *dumb_load_xm(const char *filename);
334DUH *dumb_load_s3m(const char *filename);
335DUH *dumb_load_mod(const char *filename);
336
337DUH *dumb_read_it(DUMBFILE *f);
338DUH *dumb_read_xm(DUMBFILE *f);
339DUH *dumb_read_s3m(DUMBFILE *f);
340DUH *dumb_read_mod(DUMBFILE *f);
341
342int dumb_it_sd_get_n_orders(DUMB_IT_SIGDATA *sd);
343
344int dumb_it_sd_get_initial_global_volume(DUMB_IT_SIGDATA *sd);
345void dumb_it_sd_set_initial_global_volume(DUMB_IT_SIGDATA *sd, int gv);
346
347int dumb_it_sd_get_mixing_volume(DUMB_IT_SIGDATA *sd);
348void dumb_it_sd_set_mixing_volume(DUMB_IT_SIGDATA *sd, int mv);
349
350int dumb_it_sd_get_initial_speed(DUMB_IT_SIGDATA *sd);
351void dumb_it_sd_set_initial_speed(DUMB_IT_SIGDATA *sd, int speed);
352
353int dumb_it_sd_get_initial_tempo(DUMB_IT_SIGDATA *sd);
354void dumb_it_sd_set_initial_tempo(DUMB_IT_SIGDATA *sd, int tempo);
355
356int dumb_it_sd_get_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel);
357void dumb_it_sd_set_initial_channel_volume(DUMB_IT_SIGDATA *sd, int channel, int volume);
358
359int dumb_it_sr_get_current_order(DUMB_IT_SIGRENDERER *sr);
360int dumb_it_sr_get_current_row(DUMB_IT_SIGRENDERER *sr);
361
362int dumb_it_sr_get_global_volume(DUMB_IT_SIGRENDERER *sr);
363void dumb_it_sr_set_global_volume(DUMB_IT_SIGRENDERER *sr, int gv);
364
365int dumb_it_sr_get_tempo(DUMB_IT_SIGRENDERER *sr);
366void dumb_it_sr_set_tempo(DUMB_IT_SIGRENDERER *sr, int tempo);
367
368int dumb_it_sr_get_speed(DUMB_IT_SIGRENDERER *sr);
369void dumb_it_sr_set_speed(DUMB_IT_SIGRENDERER *sr, int speed);
370
371#define DUMB_IT_N_CHANNELS 64
372#define DUMB_IT_N_NNA_CHANNELS 192
373#define DUMB_IT_TOTAL_CHANNELS (DUMB_IT_N_CHANNELS + DUMB_IT_N_NNA_CHANNELS)
374
375/* Channels passed to any of these functions are 0-based */
376int dumb_it_sr_get_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel);
377void dumb_it_sr_set_channel_volume(DUMB_IT_SIGRENDERER *sr, int channel, int volume);
378
379typedef struct DUMB_IT_CHANNEL_STATE DUMB_IT_CHANNEL_STATE;
380
381struct DUMB_IT_CHANNEL_STATE
382{
383 int channel; /* 0-based; meaningful for NNA channels */
384 int sample; /* 1-based; 0 if nothing playing, then other fields undef */
385 int freq; /* in Hz */
386 float volume; /* 1.0 maximum; affected by ALL factors, inc. mixing vol */
387 unsigned char pan; /* 0-64, 100 for surround */
388 signed char subpan; /* use (pan + subpan/256.0f) or ((pan<<8)+subpan) */
389 unsigned char filter_cutoff; /* 0-127 cutoff=127 AND resonance=0 */
390 unsigned char filter_subcutoff; /* 0-255 -> no filters (subcutoff */
391 unsigned char filter_resonance; /* 0-127 always 0 in this case) */
392 /* subcutoff only changes from zero if filter envelopes are in use. The
393 * calculation (filter_cutoff + filter_subcutoff/256.0f) gives a more
394 * accurate filter cutoff measurement as a float. It would often be more
395 * useful to use a scaled int such as ((cutoff<<8) + subcutoff).
396 */
397};
398
399/* Values of 64 or more will access NNA channels here. */
400void dumb_it_sr_get_channel_state(DUMB_IT_SIGRENDERER *sr, int channel, DUMB_IT_CHANNEL_STATE *state);
401
402
403/* Signal Design Helper Values */
404
405/* Use pow(DUMB_SEMITONE_BASE, n) to get the 'delta' value to transpose up by
406 * n semitones. To transpose down, use negative n.
407 */
408#define DUMB_SEMITONE_BASE 1.059463094359295309843105314939748495817
409
410/* Use pow(DUMB_QUARTERTONE_BASE, n) to get the 'delta' value to transpose up
411 * by n quartertones. To transpose down, use negative n.
412 */
413#define DUMB_QUARTERTONE_BASE 1.029302236643492074463779317738953977823
414
415/* Use pow(DUMB_PITCH_BASE, n) to get the 'delta' value to transpose up by n
416 * units. In this case, 256 units represent one semitone; 3072 units
417 * represent one octave. These units are used by the sequence signal (SEQU).
418 */
419#define DUMB_PITCH_BASE 1.000225659305069791926712241547647863626
420
421
422/* Signal Design Function Types */
423
424typedef void sigdata_t;
425typedef void sigrenderer_t;
426
427typedef sigdata_t *(*DUH_LOAD_SIGDATA)(DUH *duh, DUMBFILE *file);
428
429typedef sigrenderer_t *(*DUH_START_SIGRENDERER)(
430 DUH *duh,
431 sigdata_t *sigdata,
432 int n_channels,
433 long pos
434);
435
436typedef void (*DUH_SIGRENDERER_SET_SIGPARAM)(
437 sigrenderer_t *sigrenderer,
438 unsigned char id, long value
439);
440
441typedef long (*DUH_SIGRENDERER_GET_SAMPLES)(
442 sigrenderer_t *sigrenderer,
443 float volume, float delta,
444 long size, sample_t **samples
445);
446
447typedef void (*DUH_SIGRENDERER_GET_CURRENT_SAMPLE)(
448 sigrenderer_t *sigrenderer,
449 float volume,
450 sample_t *samples
451);
452
453typedef void (*DUH_END_SIGRENDERER)(sigrenderer_t *sigrenderer);
454
455typedef void (*DUH_UNLOAD_SIGDATA)(sigdata_t *sigdata);
456
457
458/* Signal Design Function Registration */
459
460typedef struct DUH_SIGTYPE_DESC
461{
462 long type;
463 DUH_LOAD_SIGDATA load_sigdata;
464 DUH_START_SIGRENDERER start_sigrenderer;
465 DUH_SIGRENDERER_SET_SIGPARAM sigrenderer_set_sigparam;
466 DUH_SIGRENDERER_GET_SAMPLES sigrenderer_get_samples;
467 DUH_SIGRENDERER_GET_CURRENT_SAMPLE sigrenderer_get_current_sample;
468 DUH_END_SIGRENDERER end_sigrenderer;
469 DUH_UNLOAD_SIGDATA unload_sigdata;
470}
471DUH_SIGTYPE_DESC;
472
473void dumb_register_sigtype(DUH_SIGTYPE_DESC *desc);
474
475
476// Decide where to put these functions; new heading?
477
478sigdata_t *duh_get_raw_sigdata(DUH *duh, int sig, long type);
479
480DUH_SIGRENDERER *duh_encapsulate_raw_sigrenderer(sigrenderer_t *vsigrenderer, DUH_SIGTYPE_DESC *desc, int n_channels, long pos);
481sigrenderer_t *duh_get_raw_sigrenderer(DUH_SIGRENDERER *sigrenderer, long type);
482
483
484/* Sample Buffer Allocation Helpers */
485
486sample_t **create_sample_buffer(int n_channels, long length);
487void destroy_sample_buffer(sample_t **samples);
488
489
490/* Silencing Helper */
491
492void dumb_silence(sample_t *samples, long length);
493
494
495/* Click Removal Helpers */
496
497typedef struct DUMB_CLICK_REMOVER DUMB_CLICK_REMOVER;
498
499DUMB_CLICK_REMOVER *dumb_create_click_remover(void);
500void dumb_record_click(DUMB_CLICK_REMOVER *cr, long pos, sample_t step);
501void dumb_remove_clicks(DUMB_CLICK_REMOVER *cr, sample_t *samples, long length, float halflife);
502sample_t dumb_click_remover_get_offset(DUMB_CLICK_REMOVER *cr);
503void dumb_destroy_click_remover(DUMB_CLICK_REMOVER *cr);
504
505DUMB_CLICK_REMOVER **dumb_create_click_remover_array(int n);
506void dumb_record_click_array(int n, DUMB_CLICK_REMOVER **cr, long pos, sample_t *step);
507void dumb_record_click_negative_array(int n, DUMB_CLICK_REMOVER **cr, long pos, sample_t *step);
508void dumb_remove_clicks_array(int n, DUMB_CLICK_REMOVER **cr, sample_t **samples, long length, float halflife);
509void dumb_click_remover_get_offset_array(int n, DUMB_CLICK_REMOVER **cr, sample_t *offset);
510void dumb_destroy_click_remover_array(int n, DUMB_CLICK_REMOVER **cr);
511
512
513/* Resampling Helpers */
514
515#define DUMB_RQ_ALIASING 0
516#define DUMB_RQ_LINEAR 1
517#define DUMB_RQ_CUBIC 2
518#define DUMB_RQ_N_LEVELS 3
519extern int dumb_resampling_quality;
520
521typedef struct DUMB_RESAMPLER DUMB_RESAMPLER;
522
523typedef void (*DUMB_RESAMPLE_PICKUP)(DUMB_RESAMPLER *resampler, void *data);
524
525struct DUMB_RESAMPLER
526{
527 sample_t *src;
528 long pos;
529 int subpos;
530 long start, end;
531 int dir;
532 DUMB_RESAMPLE_PICKUP pickup;
533 void *pickup_data;
534 int min_quality;
535 int max_quality;
536 /* Everything below this point is internal: do not use. */
537 sample_t x[3];
538 int overshot;
539};
540
541void dumb_reset_resampler(DUMB_RESAMPLER *resampler, sample_t *src, long pos, long start, long end);
542DUMB_RESAMPLER *dumb_start_resampler(sample_t *src, long pos, long start, long end);
543long dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, long dst_size, float volume, float delta);
544sample_t dumb_resample_get_current_sample(DUMB_RESAMPLER *resampler, float volume);
545void dumb_end_resampler(DUMB_RESAMPLER *resampler);
546
547
548/* DUH Construction */
549
550DUH *make_duh(
551 long length,
552 int n_signals,
553 DUH_SIGTYPE_DESC *desc[],
554 sigdata_t *sigdata[]
555);
556
557
558#ifdef __cplusplus
559 }
560#endif
561
562
563#endif /* DUMB_H */
diff --git a/apps/codecs/dumb/include/internal/aldumb.h b/apps/codecs/dumb/include/internal/aldumb.h
new file mode 100644
index 0000000000..a0c6d63c07
--- /dev/null
+++ b/apps/codecs/dumb/include/internal/aldumb.h
@@ -0,0 +1,27 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * internal/aldumb.h - The internal header file / / \ \
12 * for DUMB with Allegro. | < / \_
13 * | \/ /\ /
14 * \_ / > /
15 * | \ / /
16 * | ' /
17 * \__/
18 */
19
20#ifndef INTERNAL_ALDUMB_H
21#define INTERNAL_ALDUMB_H
22
23
24void _dat_unload_duh(void *duh);
25
26
27#endif /* INTERNAL_DUMB_H */
diff --git a/apps/codecs/dumb/include/internal/dumb.h b/apps/codecs/dumb/include/internal/dumb.h
new file mode 100644
index 0000000000..b4cd0ab1c4
--- /dev/null
+++ b/apps/codecs/dumb/include/internal/dumb.h
@@ -0,0 +1,58 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * internal/dumb.h - DUMB's internal declarations. / / \ \
12 * | < / \_
13 * This header file provides access to the | \/ /\ /
14 * internal structure of DUMB, and is liable \_ / > /
15 * to change, mutate or cease to exist at any | \ / /
16 * moment. Include it at your own peril. | ' /
17 * \__/
18 * ...
19 *
20 * I mean it, people. You don't need access to anything in this file. If you
21 * disagree, contact the authors. In the unlikely event that you make a good
22 * case, we'll add what you need to dumb.h. Thanking you kindly.
23 */
24
25#ifndef INTERNAL_DUMB_H
26#define INTERNAL_DUMB_H
27
28
29typedef struct DUH_SIGTYPE_DESC_LINK
30{
31 struct DUH_SIGTYPE_DESC_LINK *next;
32 DUH_SIGTYPE_DESC *desc;
33}
34DUH_SIGTYPE_DESC_LINK;
35
36
37typedef struct DUH_SIGNAL
38{
39 sigdata_t *sigdata;
40 DUH_SIGTYPE_DESC *desc;
41}
42DUH_SIGNAL;
43
44
45struct DUH
46{
47 long length;
48
49 int n_signals;
50 DUH_SIGNAL **signal;
51};
52
53
54DUH_SIGTYPE_DESC *_dumb_get_sigtype_desc(long type);
55
56
57#endif /* INTERNAL_DUMB_H */
58
diff --git a/apps/codecs/dumb/include/internal/it.h b/apps/codecs/dumb/include/internal/it.h
new file mode 100644
index 0000000000..7fffed6e6b
--- /dev/null
+++ b/apps/codecs/dumb/include/internal/it.h
@@ -0,0 +1,710 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * internal/it.h - Internal stuff for IT playback / / \ \
12 * and MOD/XM/S3M conversion. | < / \_
13 * | \/ /\ /
14 * \_ / > /
15 * | \ / /
16 * | ' /
17 * \__/
18 */
19
20#ifndef INTERNAL_IT_H
21#define INTERNAL_IT_H
22
23
24
25#include <stddef.h>
26
27
28
29/** TO DO: THINK ABOUT THE FOLLOWING:
30
31sigdata->flags & IT_COMPATIBLE_GXX
32
33 Bit 5: On = Link Effect G's memory with Effect E/F. Also
34 Gxx with an instrument present will cause the
35 envelopes to be retriggered. If you change a
36 sample on a row with Gxx, it'll adjust the
37 frequency of the current note according to:
38
39 NewFrequency = OldFrequency * NewC5 / OldC5;
40*/
41
42
43
44/* These #defines are TEMPORARY. They are used to write alternative code to
45 * handle ambiguities in the format specification. The correct code in each
46 * case will be determined most likely by experimentation.
47 */
48#define STEREO_SAMPLES_COUNT_AS_TWO
49#define INVALID_ORDERS_END_SONG
50#define INVALID_NOTES_CAUSE_NOTE_CUT
51#define SUSTAIN_LOOP_OVERRIDES_NORMAL_LOOP
52#define VOLUME_OUT_OF_RANGE_SETS_MAXIMUM
53
54
55
56#define SIGTYPE_IT DUMB_ID('I', 'T', ' ', ' ')
57
58#define IT_SIGNATURE DUMB_ID('I', 'M', 'P', 'M')
59#define IT_INSTRUMENT_SIGNATURE DUMB_ID('I', 'M', 'P', 'I')
60#define IT_SAMPLE_SIGNATURE DUMB_ID('I', 'M', 'P', 'S')
61
62
63
64/* 1 minute per 4 rows, each row 6 ticks; this is divided by the tempo to get
65 * the interval between ticks.
66 */
67#define TICK_TIME_DIVIDEND ((65536 * 60) / (4 * 6))
68
69
70
71/* I'm not going to try to explain this, because I didn't derive it very
72 * formally ;)
73 */
74/* #define AMIGA_DIVISOR ((float)(4.0 * 14317056.0)) */
75/* I believe the following one to be more accurate. */
76#define AMIGA_DIVISOR ((float)(8.0 * 7159090.5))
77
78
79
80typedef struct IT_MIDI IT_MIDI;
81typedef struct IT_FILTER_STATE IT_FILTER_STATE;
82typedef struct IT_ENVELOPE IT_ENVELOPE;
83typedef struct IT_INSTRUMENT IT_INSTRUMENT;
84typedef struct IT_SAMPLE IT_SAMPLE;
85typedef struct IT_ENTRY IT_ENTRY;
86typedef struct IT_PATTERN IT_PATTERN;
87typedef struct IT_PLAYING_ENVELOPE IT_PLAYING_ENVELOPE;
88typedef struct IT_PLAYING IT_PLAYING;
89typedef struct IT_CHANNEL IT_CHANNEL;
90typedef struct IT_CHECKPOINT IT_CHECKPOINT;
91typedef struct IT_CALLBACKS IT_CALLBACKS;
92
93
94
95struct IT_MIDI
96{
97 unsigned char SFmacro[16][16]; // read these from 0x120
98 unsigned char SFmacrolen[16];
99 unsigned short SFmacroz[16]; /* Bitfield; bit 0 set = z in first position */
100 unsigned char Zmacro[128][16]; // read these from 0x320
101 unsigned char Zmacrolen[128];
102};
103
104
105
106struct IT_FILTER_STATE
107{
108 float currsample, prevsample;
109};
110
111
112
113#define IT_ENVELOPE_ON 1
114#define IT_ENVELOPE_LOOP_ON 2
115#define IT_ENVELOPE_SUSTAIN_LOOP 4
116#define IT_ENVELOPE_PITCH_IS_FILTER 128
117
118struct IT_ENVELOPE
119{
120 unsigned char flags;
121 unsigned char n_nodes;
122 unsigned char loop_start;
123 unsigned char loop_end;
124 unsigned char sus_loop_start;
125 unsigned char sus_loop_end;
126 signed char node_y[25];
127 unsigned short node_t[25];
128};
129
130
131
132#define NNA_NOTE_CUT 0
133#define NNA_NOTE_CONTINUE 1
134#define NNA_NOTE_OFF 2
135#define NNA_NOTE_FADE 3
136
137#define DCT_OFF 0
138#define DCT_NOTE 1
139#define DCT_SAMPLE 2
140#define DCT_INSTRUMENT 3
141
142#define DCA_NOTE_CUT 0
143#define DCA_NOTE_OFF 1
144#define DCA_NOTE_FADE 2
145
146struct IT_INSTRUMENT
147{
148 int fadeout;
149
150 IT_ENVELOPE volume_envelope;
151 IT_ENVELOPE pan_envelope;
152 IT_ENVELOPE pitch_envelope;
153
154 unsigned char new_note_action;
155 unsigned char dup_check_type;
156 unsigned char dup_check_action;
157 unsigned char pp_separation;
158 unsigned char pp_centre;
159 unsigned char global_volume;
160 unsigned char default_pan;
161 unsigned char random_volume;
162 unsigned char random_pan;
163
164 unsigned char filter_cutoff;
165 unsigned char filter_resonance;
166
167 unsigned char map_note[120];
168 unsigned short map_sample[120];
169};
170
171
172
173#define IT_SAMPLE_EXISTS 1
174#define IT_SAMPLE_16BIT 2
175#define IT_SAMPLE_STEREO 4
176#define IT_SAMPLE_LOOP 16
177#define IT_SAMPLE_SUS_LOOP 32
178#define IT_SAMPLE_PINGPONG_LOOP 64
179#define IT_SAMPLE_PINGPONG_SUS_LOOP 128
180
181#define IT_VIBRATO_SINE 0
182#define IT_VIBRATO_SAWTOOTH 1 /* Ramp down */
183#define IT_VIBRATO_SQUARE 2
184#define IT_VIBRATO_RANDOM 3
185
186struct IT_SAMPLE
187{
188 unsigned char flags;
189 unsigned char global_volume;
190 unsigned char default_volume;
191 unsigned char default_pan;
192
193 long length;
194 long loop_start;
195 long loop_end;
196 long C5_speed;
197 long sus_loop_start;
198 long sus_loop_end;
199
200 unsigned char vibrato_speed;
201 unsigned char vibrato_depth;
202 unsigned char vibrato_rate;
203 unsigned char vibrato_waveform;
204
205 sample_t *left;
206 sample_t *right;
207};
208
209
210
211#define IT_ENTRY_NOTE 1
212#define IT_ENTRY_INSTRUMENT 2
213#define IT_ENTRY_VOLPAN 4
214#define IT_ENTRY_EFFECT 8
215
216#define IT_SET_END_ROW(entry) ((entry)->channel = 255)
217#define IT_IS_END_ROW(entry) ((entry)->channel >= DUMB_IT_N_CHANNELS)
218
219#define IT_NOTE_OFF 255
220#define IT_NOTE_CUT 254
221
222#define IT_ENVELOPE_SHIFT 8
223
224#define IT_SURROUND 100
225#define IT_IS_SURROUND(pan) ((pan) > 64)
226#define IT_IS_SURROUND_SHIFTED(pan) ((pan) > 64 << IT_ENVELOPE_SHIFT)
227
228#define IT_SET_SPEED 1
229#define IT_JUMP_TO_ORDER 2
230#define IT_BREAK_TO_ROW 3
231#define IT_VOLUME_SLIDE 4
232#define IT_PORTAMENTO_DOWN 5
233#define IT_PORTAMENTO_UP 6
234#define IT_TONE_PORTAMENTO 7
235#define IT_VIBRATO 8
236#define IT_TREMOR 9
237#define IT_ARPEGGIO 10
238#define IT_VOLSLIDE_VIBRATO 11
239#define IT_VOLSLIDE_TONEPORTA 12
240#define IT_SET_CHANNEL_VOLUME 13
241#define IT_CHANNEL_VOLUME_SLIDE 14
242#define IT_SET_SAMPLE_OFFSET 15
243#define IT_PANNING_SLIDE 16
244#define IT_RETRIGGER_NOTE 17
245#define IT_TREMOLO 18
246#define IT_S 19
247#define IT_SET_SONG_TEMPO 20
248#define IT_FINE_VIBRATO 21
249#define IT_SET_GLOBAL_VOLUME 22
250#define IT_GLOBAL_VOLUME_SLIDE 23
251#define IT_SET_PANNING 24
252#define IT_PANBRELLO 25
253#define IT_MIDI_MACRO 26 //see MIDI.TXT
254
255/* Some effects needed for XM compatibility */
256#define IT_XM_PORTAMENTO_DOWN 27
257#define IT_XM_PORTAMENTO_UP 28
258#define IT_XM_FINE_VOLSLIDE_DOWN 29
259#define IT_XM_FINE_VOLSLIDE_UP 30
260#define IT_XM_RETRIGGER_NOTE 31
261
262#define IT_N_EFFECTS 32
263
264/* These represent the top nibble of the command value. */
265#define IT_S_SET_FILTER 0 /* Greyed out in IT... */
266#define IT_S_SET_GLISSANDO_CONTROL 1 /* Greyed out in IT... */
267#define IT_S_FINETUNE 2 /* Greyed out in IT... */
268#define IT_S_SET_VIBRATO_WAVEFORM 3
269#define IT_S_SET_TREMOLO_WAVEFORM 4
270#define IT_S_SET_PANBRELLO_WAVEFORM 5
271#define IT_S_FINE_PATTERN_DELAY 6
272#define IT_S7 7
273#define IT_S_SET_PAN 8
274#define IT_S_SET_SURROUND_SOUND 9
275#define IT_S_SET_HIGH_OFFSET 10
276#define IT_S_PATTERN_LOOP 11
277#define IT_S_DELAYED_NOTE_CUT 12
278#define IT_S_NOTE_DELAY 13
279#define IT_S_PATTERN_DELAY 14
280#define IT_S_SET_MIDI_MACRO 15
281
282/*
283S0x Set filter
284S1x Set glissando control
285S2x Set finetune
286
287
288S3x Set vibrato waveform to type x
289S4x Set tremelo waveform to type x
290S5x Set panbrello waveform to type x
291 Waveforms for commands S3x, S4x and S5x:
292 0: Sine wave
293 1: Ramp down
294 2: Square wave
295 3: Random wave
296S6x Pattern delay for x ticks
297S70 Past note cut
298S71 Past note off
299S72 Past note fade
300S73 Set NNA to note cut
301S74 Set NNA to continue
302S75 Set NNA to note off
303S76 Set NNA to note fade
304S77 Turn off volume envelope
305S78 Turn on volume envelope
306S79 Turn off panning envelope
307S7A Turn on panning envelope
308S7B Turn off pitch envelope
309S7C Turn on pitch envelope
310S8x Set panning position
311S91 Set surround sound
312SAy Set high value of sample offset yxx00h
313SB0 Set loopback point
314SBx Loop x times to loopback point
315SCx Note cut after x ticks
316SDx Note delay for x ticks
317SEx Pattern delay for x rows
318SFx Set parameterised MIDI Macro
319*/
320
321struct IT_ENTRY
322{
323 unsigned char channel; /* End of row if channel >= DUMB_IT_N_CHANNELS */
324 unsigned char mask;
325 unsigned char note;
326 unsigned char instrument;
327 unsigned char volpan;
328 unsigned char effect;
329 unsigned char effectvalue;
330};
331
332
333
334struct IT_PATTERN
335{
336 int n_rows;
337 int n_entries;
338 IT_ENTRY *entry;
339};
340
341
342
343#define IT_STEREO 1
344#define IT_USE_INSTRUMENTS 4
345#define IT_LINEAR_SLIDES 8 /* If not set, use Amiga slides */
346#define IT_OLD_EFFECTS 16
347#define IT_COMPATIBLE_GXX 32
348
349/* Make sure IT_WAS_AN_XM and IT_WAS_A_MOD aren't set accidentally */
350#define IT_REAL_FLAGS 63
351
352#define IT_WAS_AN_XM 64 /* Set for both XMs and MODs */
353#define IT_WAS_A_MOD 128
354
355#define IT_ORDER_END 255
356#define IT_ORDER_SKIP 254
357
358struct DUMB_IT_SIGDATA
359{
360 int n_orders;
361 int n_instruments;
362 int n_samples;
363 int n_patterns;
364
365 int flags;
366
367 int global_volume;
368 int mixing_volume;
369 int speed;
370 int tempo;
371 int pan_separation;
372
373 unsigned char channel_pan[DUMB_IT_N_CHANNELS];
374 unsigned char channel_volume[DUMB_IT_N_CHANNELS];
375
376 unsigned char *order;
377 unsigned char restart_position; /* for XM compatiblity */
378
379 IT_INSTRUMENT *instrument;
380 IT_SAMPLE *sample;
381 IT_PATTERN *pattern;
382
383 IT_MIDI *midi;
384
385 IT_CHECKPOINT *checkpoint;
386};
387
388
389
390struct IT_PLAYING_ENVELOPE
391{
392 int next_node;
393 int tick;
394};
395
396
397
398#define IT_PLAYING_BACKGROUND 1
399#define IT_PLAYING_SUSTAINOFF 2
400#define IT_PLAYING_FADING 4
401#define IT_PLAYING_DEAD 8
402
403struct IT_PLAYING
404{
405 int flags;
406
407 IT_CHANNEL *channel;
408 IT_SAMPLE *sample;
409 IT_INSTRUMENT *instrument;
410 IT_INSTRUMENT *env_instrument;
411
412 unsigned short sampnum;
413 unsigned char instnum;
414
415 unsigned char channel_volume;
416
417 unsigned char volume;
418 unsigned short pan;
419
420 unsigned char note;
421
422 unsigned char filter_cutoff;
423 unsigned char filter_resonance;
424
425 unsigned short true_filter_cutoff; /* These incorporate the filter envelope, and will not */
426 unsigned char true_filter_resonance; /* be changed if they would be set to 127<<8 and 0. */
427
428 unsigned char vibrato_speed;
429 unsigned char vibrato_depth;
430 unsigned char vibrato_n; /* May be specified twice: volpan & effect. */
431 unsigned char vibrato_time;
432
433 unsigned char tremolo_speed;
434 unsigned char tremolo_depth;
435 unsigned char tremolo_time;
436
437 unsigned char sample_vibrato_time;
438 int sample_vibrato_depth; /* Starts at rate?0:depth, increases by rate */
439
440 int slide;
441 float delta;
442
443 IT_PLAYING_ENVELOPE volume_envelope;
444 IT_PLAYING_ENVELOPE pan_envelope;
445 IT_PLAYING_ENVELOPE pitch_envelope;
446
447 int fadeoutcount;
448
449 IT_FILTER_STATE filter_state[2]; /* Left and right */
450
451 DUMB_RESAMPLER resampler[2];
452
453 /* time_lost is used to emulate Impulse Tracker's sample looping
454 * characteristics. When time_lost is added to pos, the result represents
455 * the position in the theoretical version of the sample where all loops
456 * have been expanded. If this is stored, the resampling helpers will
457 * safely convert it for use with new loop boundaries. The situation is
458 * slightly more complicated if dir == -1 when the change takes place; we
459 * must reflect pos off the loop end point and set dir to 1 before
460 * proceeding.
461 */
462 long time_lost;
463};
464
465
466
467#define IT_CHANNEL_MUTED 1
468
469struct IT_CHANNEL
470{
471 int flags;
472
473 unsigned char volume;
474 signed char volslide;
475 signed char xm_volslide;
476
477 /* xm_volslide is used for volume slides done in the volume column in an
478 * XM file, since it seems the volume column slide is applied first,
479 * followed by clamping, followed by the effects column slide. IT does
480 * not exhibit this behaviour, so xm_volslide is maintained at zero.
481 */
482
483 unsigned char pan;
484 unsigned short truepan;
485
486 unsigned char channelvolume;
487 signed char channelvolslide;
488
489 unsigned char instrument;
490 unsigned char note;
491
492 unsigned char SFmacro;
493
494 unsigned char filter_cutoff;
495 unsigned char filter_resonance;
496
497 unsigned char note_cut_count;
498 unsigned char note_delay_count;
499 IT_ENTRY *note_delay_entry;
500
501 int arpeggio;
502 unsigned char retrig;
503 unsigned char xm_retrig;
504 int retrig_tick;
505
506 unsigned char tremor;
507 unsigned char tremor_time; /* Bit 6 set if note on; bit 7 set if tremor active. */
508
509 int portamento;
510 int toneporta;
511 unsigned char destnote;
512
513 /** WARNING - for neatness, should one or both of these be in the IT_PLAYING struct? */
514 unsigned short sample;
515 unsigned char truenote;
516
517 unsigned char midi_state;
518
519 signed char lastvolslide;
520 unsigned char lastDKL;
521 unsigned char lastEF; /* Doubles as last portamento up for XM files */
522 unsigned char lastG;
523 unsigned char lastHspeed;
524 unsigned char lastHdepth;
525 unsigned char lastRspeed;
526 unsigned char lastRdepth;
527 unsigned char lastI;
528 unsigned char lastJ; /* Doubles as last portamento down for XM files */
529 unsigned char lastN;
530 unsigned char lastO;
531 unsigned char high_offset;
532 unsigned char lastQ;
533 unsigned char lastS;
534 unsigned char pat_loop_row;
535 unsigned char pat_loop_count;
536 unsigned char lastW;
537
538 unsigned char xm_lastE1;
539 unsigned char xm_lastE2;
540 unsigned char xm_lastEA;
541 unsigned char xm_lastEB;
542 unsigned char xm_lastX1;
543 unsigned char xm_lastX2;
544
545 IT_PLAYING *playing;
546};
547
548
549
550struct DUMB_IT_SIGRENDERER
551{
552 DUMB_IT_SIGDATA *sigdata;
553
554 int n_channels;
555
556 unsigned char globalvolume;
557 signed char globalvolslide;
558
559 unsigned char tempo;
560 signed char temposlide;
561
562 IT_CHANNEL channel[DUMB_IT_N_CHANNELS];
563
564 IT_PLAYING *playing[DUMB_IT_N_NNA_CHANNELS];
565
566 int tick;
567 int speed;
568 int rowcount;
569
570 int order; /* Set to -1 if the song is terminated by a callback. */
571 int row;
572 int processorder;
573 int processrow;
574 int breakrow;
575 int pat_loop_row;
576
577 int n_rows;
578
579 IT_ENTRY *entry_start;
580 IT_ENTRY *entry;
581 IT_ENTRY *entry_end;
582
583 long time_left; /* Time before the next tick is processed */
584 int sub_time_left;
585
586 DUMB_CLICK_REMOVER **click_remover;
587
588 IT_CALLBACKS *callbacks;
589};
590
591
592
593struct IT_CHECKPOINT
594{
595 IT_CHECKPOINT *next;
596 long time;
597 DUMB_IT_SIGRENDERER *sigrenderer;
598};
599
600
601
602struct IT_CALLBACKS
603{
604 int (*loop)(void *data);
605 void *loop_data;
606 /* Return 1 to prevent looping; the music will terminate abruptly. If you
607 * want to make the music stop but allow samples to fade (beware, as they
608 * might not fade at all!), use dumb_it_sr_set_speed() and set the speed
609 * to 0. Note that xm_speed_zero() will not be called if you set the
610 * speed manually, and also that this will work for IT and S3M files even
611 * though the music can't stop in this way by itself.
612 */
613
614 int (*xm_speed_zero)(void *data);
615 void *xm_speed_zero_data;
616 /* Return 1 to terminate the mod, without letting samples fade. */
617
618 int (*midi)(void *data, int channel, unsigned char byte);
619 void *midi_data;
620 /* Return 1 to prevent DUMB from subsequently interpreting the MIDI bytes
621 * itself. In other words, return 1 if the Zxx macros in an IT file are
622 * controlling filters and shouldn't be.
623 */
624};
625
626
627
628void _dumb_it_end_sigrenderer(sigrenderer_t *sigrenderer);
629void _dumb_it_unload_sigdata(sigdata_t *vsigdata);
630
631extern DUH_SIGTYPE_DESC _dumb_sigtype_it;
632
633
634
635long _dumb_it_build_checkpoints(DUMB_IT_SIGDATA *sigdata);
636
637
638
639#define XM_APPREGIO 0
640#define XM_PORTAMENTO_UP 1
641#define XM_PORTAMENTO_DOWN 2
642#define XM_TONE_PORTAMENTO 3
643#define XM_VIBRATO 4
644#define XM_VOLSLIDE_TONEPORTA 5
645#define XM_VOLSLIDE_VIBRATO 6
646#define XM_TREMOLO 7
647#define XM_SET_PANNING 8
648#define XM_SAMPLE_OFFSET 9
649#define XM_VOLUME_SLIDE 10 /* A */
650#define XM_POSITION_JUMP 11 /* B */
651#define XM_SET_CHANNEL_VOLUME 12 /* C */
652#define XM_PATTERN_BREAK 13 /* D */
653#define XM_E 14 /* E */
654#define XM_SET_TEMPO_BPM 15 /* F */
655#define XM_SET_GLOBAL_VOLUME 16 /* G */
656#define XM_GLOBAL_VOLUME_SLIDE 17 /* H */
657#define XM_KEY_OFF 20 /* K (undocumented) */
658#define XM_SET_ENVELOPE_POSITION 21 /* L */
659#define XM_PANNING_SLIDE 25 /* P */
660#define XM_MULTI_RETRIG 27 /* R */
661#define XM_TREMOR 29 /* T */
662#define XM_X 33 /* X */
663#define XM_N_EFFECTS (10+26)
664
665#define XM_E_SET_FILTER 0x0
666#define XM_E_FINE_PORTA_UP 0x1
667#define XM_E_FINE_PORTA_DOWN 0x2
668#define XM_E_SET_GLISSANDO_CONTROL 0x3
669#define XM_E_SET_VIBRATO_CONTROL 0x4
670#define XM_E_SET_FINETUNE 0x5
671#define XM_E_SET_LOOP 0x6
672#define XM_E_SET_TREMOLO_CONTROL 0x7
673#define XM_E_RETRIG_NOTE 0x9
674#define XM_E_FINE_VOLSLIDE_UP 0xA
675#define XM_E_FINE_VOLSLIDE_DOWN 0xB
676#define XM_E_NOTE_CUT 0xC
677#define XM_E_NOTE_DELAY 0xD
678#define XM_E_PATTERN_DELAY 0xE
679
680#define XM_X_EXTRAFINE_PORTA_UP 1
681#define XM_X_EXTRAFINE_PORTA_DOWN 2
682
683/* To make my life a bit simpler during conversion, effect E:xy is converted
684 * to effect number EBASE+x:y. The same applies to effect X, and IT's S. That
685 * way, these effects can be manipulated like regular effects.
686 */
687#define EBASE (XM_N_EFFECTS)
688#define XBASE (EBASE+16)
689#define SBASE (IT_N_EFFECTS)
690
691#define EFFECT_VALUE(x, y) (((x)<<4)|(y))
692#define HIGH(v) ((v)>>4)
693#define LOW(v) ((v)&0x0F)
694#define SET_HIGH(v, x) v = (((x)<<4)|((v)&0x0F))
695#define SET_LOW(v, y) v = (((v)&0xF0)|(y))
696#define BCD_TO_NORMAL(v) (HIGH(v)*10+LOW(v))
697
698
699
700#if 0
701unsigned char **_dumb_malloc2(int w, int h);
702void _dumb_free2(unsigned char **line);
703#endif
704
705void _dumb_it_xm_convert_effect(int effect, int value, IT_ENTRY *entry);
706int _dumb_it_fix_invalid_orders(DUMB_IT_SIGDATA *sigdata);
707
708
709
710#endif /* INTERNAL_IT_H */