-
Notifications
You must be signed in to change notification settings - Fork 3
/
JUDAS.H
267 lines (236 loc) · 6.67 KB
/
JUDAS.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#ifdef __DJGPP__
#define HANDLE_PRAGMA_PACK_PUSH_POP 1
#endif
/*
* JUDAS main header file
*/
#include "judascfg.h"
#include "judaserr.h"
/*
* Mixer numbers
*/
#define FASTMIXER 1
#define QUALITYMIXER 2
/*
* Mixmode bits
*/
#define MONO 0
#define STEREO 1
#define EIGHTBIT 0
#define SIXTEENBIT 2
/*
* Sound device numbers
*/
#define DEV_NOSOUND 0
#define DEV_SB 1
#define DEV_SBPRO 2
#define DEV_SB16 3
#define DEV_GUS 4
#define DEV_AC97 5
#define DEV_HDA 6
#define DEV_FILE 7
/*
* Voicemode bits
*/
#define VM_OFF 0
#define VM_ON 1
#define VM_ONESHOT 0
#define VM_LOOP 2
#define VM_16BIT 4
/*
* Panning values (these specific panning positions are mixed with optimized
* routines which greatly reduce processing time if fast mixer is used!)
*/
#define LEFT 0
#define MIDDLE 128
#define RIGHT 255
/*
* Sample structure
*/
typedef struct
{
char *start;
char *repeat;
char *end;
char *vuprofile;
unsigned char voicemode;
} SAMPLE;
/*
* Channel structure
*/
#pragma pack(push,1)
typedef struct
{
char *volatile pos; /* Position which is currently played */
char *repeat; /* Goes here after hitting end */
char *end; /* Position of last sample + 1 */
SAMPLE *volatile smp; /* Pointer to sample currently used */
unsigned freq; /* Playing frequency in hertz */
volatile unsigned short fractpos; /* 16bit fractional pos */
unsigned char mastervol; /* 255 = whole volume range of output */
unsigned char panning; /* 0 left, 128 middle, 255 right */
signed short vol; /* Note volume, ranges from 0 to 64*256 */
volatile unsigned char voicemode; /* See the bit definitions above */
/* Quality mixer internal variables (No need to understand) */
volatile char prevvm; /* voicemode != prevvm if discontinuity in the sound */
char *volatile prevpos; /* Pos != prevpos if discontinuity in the sound */
volatile int lastvalleft; /* Last value from prev. mixed chunk (after volume scaling) */
volatile int lastvalright;
volatile int smoothvoll; /* Final volume. Smoothly slided towards given volume */
volatile int smoothvolr;
} CHANNEL;
#pragma pack(pop)
/*
* General functions
*/
void judas_config(void);
int judas_init(unsigned mixrate, unsigned mixer, unsigned mixmode, int interpolation);
void judas_update(void);
void judas_uninit(void);
int judas_songisplaying(void);
/*
* Sample & channel functions
*/
SAMPLE *judas_allocsample(int length);
void judas_ipcorrect(SAMPLE *smp);
void judas_freesample(SAMPLE *smp);
void judas_playsample(SAMPLE *smp, unsigned chnum, unsigned frequency, unsigned short volume, unsigned char panning);
void judas_stopsample(unsigned chnum);
void judas_preventdistortion(unsigned active_channels);
void judas_setmastervolume(unsigned chnum, unsigned char mastervol);
void judas_setmusicmastervolume(unsigned musicchannels, unsigned char mastervol);
void judas_setsfxmastervolume(unsigned musicchannels, unsigned char mastervol);
float judas_getvumeter(unsigned chnum); /* Returns 0..1 */
/*
* RAW sample & WAV functions
*/
SAMPLE *judas_loadrawsample(char *name, int repeat, int end, unsigned char voicemode);
SAMPLE *judas_loadwav(char *name);
void judas_setwavlib(char *name);
/*
* WAV writer functions
*/
int judas_wavwriter_open(char *name);
int judas_wavwriter_writesome(int handle);
int judas_wavwriter_close(int handle);
/*
* XM player functions
*/
int judas_loadxm(char *name);
void judas_freexm(void);
void judas_playxm(int rounds);
void judas_stopxm(void);
void judas_forwardxm(void);
void judas_rewindxm(void);
unsigned char judas_getxmpos(void);
unsigned char judas_getxmline(void);
unsigned char judas_getxmtick(void);
unsigned char judas_getxmchannels(void);
char *judas_getxmname(void);
/*
* MOD player functions
*/
int judas_loadmod(char *name);
void judas_freemod(void);
void judas_playmod(int rounds);
void judas_stopmod(void);
void judas_forwardmod(void);
void judas_rewindmod(void);
unsigned char judas_getmodpos(void);
unsigned char judas_getmodline(void);
unsigned char judas_getmodtick(void);
unsigned char judas_getmodchannels(void);
char *judas_getmodname(void);
/*
* S3M player functions
*/
int judas_loads3m(char *name);
void judas_frees3m(void);
void judas_plays3m(int rounds);
void judas_stops3m(void);
void judas_forwards3m(void);
void judas_rewinds3m(void);
unsigned char judas_gets3mpos(void);
unsigned char judas_gets3mline(void);
unsigned char judas_gets3mtick(void);
unsigned char judas_gets3mchannels(void);
char *judas_gets3mname(void);
/*
* JUDAS IO functions
*/
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
int judas_open(char *name);
int judas_seek(int handle, int bytes, int whence);
int judas_read(int handle, void *buffer, int size);
void judas_close(int handle);
/*
* DPMI memory locking functions (use them, and no more crashes under
* multitaskers!)
*/
int judas_memlock(void *start, unsigned size);
int judas_memunlock(void *start, unsigned size);
void *locked_malloc(int size);
void locked_free(void *address);
void *dos_malloc(int size);
void dos_free(void *address);
int DPMI_MapMemory (unsigned long *physaddress, unsigned long *linaddress, unsigned long size);
int DPMI_UnmapMemory (unsigned long *linaddress);
/*
* Sound configuration (may be changed anytime, used only by judas_init())
*/
extern unsigned judascfg_device;
extern unsigned judascfg_port;
extern unsigned judascfg_irq;
extern unsigned judascfg_dma1;
extern unsigned judascfg_dma2; /* SB High DMA, not needed for GUS */
/*
* Device, port, IRQ, DMA, mixrate & mixmode currently in use.
* Don't change them!
*/
extern unsigned judas_device;
extern unsigned judas_port;
extern unsigned judas_irq;
extern unsigned judas_dma;
extern unsigned judas_mixrate;
extern unsigned char judas_mixmode;
/*
* Sound device names
*/
extern char *judas_devname[];
/*
* Mixer names
*/
extern char *judas_mixername[];
/*
* Mixmode names
*/
extern char *judas_mixmodename[];
/*
* Interpolation mode names
*/
extern char *judas_ipmodename[];
/*
* Error code
*/
extern int judas_error;
/*
* Text strings for the error codes
*/
extern char *judas_errortext[];
/*
* Channel array
*/
extern CHANNEL judas_channel[CHANNELS];
/*
* Fake sample returned by the routines when in NOSOUND mode
*/
extern SAMPLE fakesample;
/*
* Clipping indicator (quality mixer only) indicates the hardest
* clipping occurred. 0 = has not clipped, 64 = clipping starts,
* 128 = half volume wouldn't clip, 255 = 1/4 volume wouldn't clip
* Does not give values in range 1..63.
*/
extern volatile char judas_clipped;