forked from Tronix286/AIL2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDIGIPLAY.C
210 lines (177 loc) · 7.31 KB
/
DIGIPLAY.C
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
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ DIGIPLAY.C ÛÛ
//ÛÛ ÛÛ
//ÛÛ Creative Voice File (.VOC) performance utility ÛÛ
//ÛÛ with dual-buffer playback ÛÛ
//ÛÛ ÛÛ
//ÛÛ Project: IBM Audio Interface Library ÛÛ
//ÛÛ Author: John Miles ÛÛ
//ÛÛ ÛÛ
//ÛÛ V2.00 of 09-Oct-91 ÛÛ
//ÛÛ V2.01 of 09-Apr-92: Preformatting call added ÛÛ
//ÛÛ ÛÛ
//ÛÛ C source compatible with Turbo C++ v1.0 or later ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ digiplay.obj: digiplay.c gen.h ail.h ÛÛ
//ÛÛ bcc -ml -c -v digiplay.c ÛÛ
//ÛÛ ÛÛ
//ÛÛ digiplay.exe: digiplay.obj gen.lib ail.obj ÛÛ
//ÛÛ tlink @digiplay.lls ÛÛ
//ÛÛ ÛÛ
//ÛÛ Contents of DIGIPLAY.LLS: ÛÛ
//ÛÛ /c /v /x + ÛÛ
//ÛÛ \bc\lib\c0l.obj + ÛÛ
//ÛÛ digiplay ail, + ÛÛ
//ÛÛ digiplay.exe, + ÛÛ
//ÛÛ digiplay.map, + ÛÛ
//ÛÛ \bc\lib\cl.lib gen.lib ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ Copyright (C) 1991, 1992 Miles Design, Inc. ÛÛ
//ÛÛ ÛÛ
//ÛÛ Miles Design, Inc. ÛÛ
//ÛÛ 10926 Jollyville #308 ÛÛ
//ÛÛ Austin, TX 78759 ÛÛ
//ÛÛ (512) 345-2642 / FAX (512) 338-9630 / BBS (512) 454-9990 ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <alloc.h>
#include <conio.h>
#include "ail.h" // Audio Interface Library API header file
#include "gen.h" // General DOS and system functions
const char VERSION[] = "2.01";
/***********************************************************/
void main(int argc, char *argv[])
{
HDRIVER hdriver;
char far *vfile;
char far *drvr;
drvr_desc *desc;
sound_buff firstblock,tempblock;
int i,done;
printf("\nDIGIPLAY version %s Copyright (C) 1991, 1992 Miles Design, Inc.\n",VERSION);
printf("-------------------------------------------------------------------------------\n\n");
if (argc != 3)
{
printf("This program plays the first Voice Block from a Creative Voice File (.VOC)\n");
printf("through any Audio Interface Library digital driver.\n\n");
printf("Usage: DIGIPLAY VOC_filename driver_filename\n");
exit(1);
}
AIL_startup();
//
// Load, install, describe, and initialize the Sound Blaster-
// compatible driver
//
drvr = load_driver(argv[2]);
if (drvr == NULL)
{
printf("Couldn't load driver.\n");
AIL_shutdown(NULL);
exit(1);
}
hdriver = AIL_register_driver(drvr);
if (hdriver==-1)
{
printf("Driver %s not compatible with linked API version.\n",
argv[2]);
AIL_shutdown(NULL);
exit(1);
}
desc = AIL_describe_driver(hdriver);
if (desc->drvr_type != DSP_DRVR)
{
printf("%s is not a digital sound driver.\n",argv[2]);
AIL_shutdown(NULL);
exit(1);
}
if (!AIL_detect_device(hdriver,desc->default_IO,desc->default_IRQ,
desc->default_DMA,desc->default_DRQ))
{
printf("Sound hardware not found.\n");
AIL_shutdown(NULL);
exit(1);
}
AIL_init_driver(hdriver,desc->default_IO,desc->default_IRQ,
desc->default_DMA,desc->default_DRQ);
//
// Read the entire .VOC file into memory
//
// (Not necessary when double-buffering, but done for simplicity)
//
vfile = read_file(argv[1],NULL);
if (vfile == NULL)
{
printf("Couldn't load %s.\n",argv[1]);
AIL_shutdown(NULL);
exit(1);
}
//
// Get the address and size of the first Voice Data block in the
// target .VOC file
//
AIL_index_VOC_block(hdriver,vfile,-1,&firstblock);
//
// Play the block as a series of double-buffered 16K chunks
//
// For this example, we disregard the fact that the entire file is
// in memory, and simulate the use of registered sound buffers to
// maintain continuous sound output as if the buffered chunks were
// actually loaded on demand from disk or extra memory
//
printf("Press any key to stop playback ");
//
// Copy sample rate and packing type to working sound buffer
// structure
//
tempblock = firstblock;
//
// Sample application main loop ...
//
done = 0;
do
{
//
// (Application-specific events here)
//
//
// Update sound DMA buffers and ensure sound output is active
//
for (i=0;i<2;i++)
if ((AIL_sound_buffer_status(hdriver,i) == DAC_DONE)
&& firstblock.len)
{
tempblock.data = firstblock.data;
tempblock.len = min(16384L,firstblock.len);
firstblock.len -= tempblock.len;
firstblock.data = (void far *) ((char huge *)
firstblock.data + tempblock.len);
AIL_format_sound_buffer(hdriver,&tempblock);
AIL_register_sound_buffer(hdriver,i,&tempblock);
printf(".");
}
AIL_start_digital_playback(hdriver);
if (kbhit()) done = 1;
//
// Playback ends when no bytes are left in the source data and
// the status of both buffers equals DAC_DONE
//
if (!firstblock.len)
if ((AIL_sound_buffer_status(hdriver,0) == DAC_DONE)
&& (AIL_sound_buffer_status(hdriver,1) == DAC_DONE))
done = 1;
}
while (!done);
while (kbhit()) getch();
printf("\n\nDIGIPLAY stopped.\n");
AIL_shutdown(NULL);
}