]> icculus.org git repositories - btb/d2x.git/blob - main/digi.h
comments/formatting
[btb/d2x.git] / main / digi.h
1 /* $Id: digi.h,v 1.3 2002-08-26 06:44:36 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Include file for sound hardware.
18  *
19  * Old Log:
20  * Revision 2.0  1995/02/27  11:28:40  john
21  * New version 2.0, which has no anonymous unions, builds with
22  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
23  *
24  * Revision 1.29  1995/02/11  12:42:00  john
25  * Added new song method, with FM bank switching..
26  *
27  * Revision 1.28  1995/02/03  17:08:26  john
28  * Changed sound stuff to allow low memory usage.
29  * Also, changed so that Sounds isn't an array of digi_sounds, it
30  * is a ubyte pointing into GameSounds, this way the digi.c code that
31  * locks sounds won't accidentally unlock a sound that is already playing, but
32  * since it's Sounds[soundno] is different, it would erroneously be unlocked.
33  *
34  * Revision 1.27  1995/02/01  22:20:31  john
35  * Added digi_is_sound_playing.
36  *
37  * Revision 1.26  1994/12/20  18:03:51  john
38  * Added loop midi flag.
39  *
40  * Revision 1.25  1994/12/13  00:46:14  john
41  * Split digi and midi volume into 2 seperate functions.
42  *
43  * Revision 1.24  1994/12/10  20:34:53  john
44  * Added digi_kill_sound_linked_to_object.
45  *
46  * Revision 1.23  1994/12/10  15:59:39  mike
47  * Fixed bug.
48  *
49  * Revision 1.22  1994/12/10  15:44:35  john
50  * Added max_distance passing for sound objects.
51  *
52  * Revision 1.21  1994/12/05  12:17:40  john
53  * Added code that locks/unlocks digital sounds on demand.
54  *
55  * Revision 1.20  1994/11/28  18:34:57  john
56  * Made the digi_max_channels cut of an old sound instead of
57  * not playing a new sound.
58  *
59  * Revision 1.19  1994/11/14  17:53:56  allender
60  * made some digi variables extern
61  *
62  * Revision 1.18  1994/10/28  14:42:58  john
63  * Added sound volumes to all sound calls.
64  *
65  * Revision 1.17  1994/10/11  15:25:37  john
66  * Added new function to play a sound once...
67  *
68  * Revision 1.16  1994/10/03  20:51:44  john
69  * Started added pause sound function; for the network I changed to
70  * packet structure a bit; never tested, though.
71  *
72  *
73  * Revision 1.15  1994/10/03  13:09:43  john
74  * Added Pause function, but never tested it yet.
75  *
76  * Revision 1.14  1994/09/30  10:09:24  john
77  * Changed sound stuff... made it so the reseting card doesn't hang,
78  * made volume change only if sound is installed.
79  *
80  * Revision 1.13  1994/09/29  21:13:43  john
81  * Added Master volumes for digi and midi. Also took out panning,
82  * because it doesn't work with MasterVolume stuff.
83  *
84  * Revision 1.12  1994/09/29  12:42:34  john
85  * Added sidenum to keep track of sound pos. Made sound functions
86  * not do anything if nosound. Made sounds_init delete currently
87  * playing sounds.
88  *
89  * Revision 1.11  1994/09/29  12:23:42  john
90  * Added digi_kill_sound_linked_to_segment function.
91  *
92  * Revision 1.10  1994/09/29  11:59:04  john
93  * Added digi_kill_sound
94  *
95  * Revision 1.9  1994/09/29  10:37:38  john
96  * Added sound objects that dynamicaly change volume,pan.
97  *
98  * Revision 1.8  1994/09/28  16:18:37  john
99  * Added capability to play midi song.
100  *
101  * Revision 1.7  1994/06/17  18:01:41  john
102  * A bunch of new stuff by John
103  *
104  * Revision 1.6  1994/06/15  19:00:58  john
105  * Added the capability to make 3d sounds play just once for the
106  * laser hit wall effects.
107  *
108  * Revision 1.5  1994/06/07  10:54:30  john
109  * Made key S reinit the sound system.
110  *
111  * Revision 1.4  1994/05/09  21:11:39  john
112  * Sound changes; pass index instead of pointer to digi routines.
113  * Made laser sound cut off the last laser sound.
114  *
115  * Revision 1.3  1994/04/27  11:44:25  john
116  * First version of sound! Yay!
117  *
118  * Revision 1.2  1994/04/20  21:58:50  john
119  * First version of sound stuff... hopefully everything
120  * is commented out because it hangs..
121  *
122  * Revision 1.1  1994/04/15  14:25:02  john
123  * Initial revision
124  *
125  *
126  */
127
128
129
130 #ifndef _DIGI_H
131 #define _DIGI_H
132
133 #include "pstypes.h"
134 #include "vecmat.h"
135
136 /*
137 #ifdef __DJGPP__
138 #define ALLEGRO
139 #endif
140 */
141
142 #ifdef ALLEGRO
143 #include "allg_snd.h"
144 typedef SAMPLE digi_sound;
145 #else
146 typedef struct digi_sound       {
147         int bits;
148         int freq;
149         int length;
150         ubyte * data;
151 } digi_sound;
152 #endif
153
154 #define SAMPLE_RATE_11K         11025
155 #define SAMPLE_RATE_22K         22050
156
157
158
159 #ifdef __DJGPP__
160 extern int digi_driver_board;
161 extern int digi_driver_port;
162 extern int digi_driver_irq;
163 extern int digi_driver_dma;
164 extern int digi_midi_type;
165 extern int digi_midi_port;
166 #endif
167
168 extern int digi_sample_rate;
169
170 extern int digi_get_settings();
171 extern int digi_init();
172 extern void digi_reset();
173 extern void digi_close();
174
175 int digi_xlat_sound(int sound);
176 // Volume is max at F1_0.
177 extern void digi_play_sample( int sndnum, fix max_volume );
178 extern void digi_play_sample_once( int sndnum, fix max_volume );
179 extern int digi_link_sound_to_object( int soundnum, short objnum, int forever, fix max_volume );
180 extern int digi_link_sound_to_pos( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume );
181 // Same as above, but you pass the max distance sound can be heard.  The old way uses f1_0*256 for max_distance.
182 extern int digi_link_sound_to_object2( int soundnum, short objnum, int forever, fix max_volume, fix  max_distance );
183 extern int digi_link_sound_to_pos2( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance );
184
185 extern int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix max_volume, fix  max_distance, int loop_start, int loop_end );
186
187 extern void digi_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop );
188
189 extern void digi_play_sample_3d( int soundno, int angle, int volume, int no_dups ); // Volume from 0-0x7fff
190
191 extern void digi_init_sounds();
192 extern void digi_sync_sounds();
193 extern void digi_kill_sound_linked_to_segment( int segnum, int sidenum, int soundnum );
194 extern void digi_kill_sound_linked_to_object( int objnum );
195
196 extern void digi_set_midi_volume( int mvolume );
197 extern void digi_set_digi_volume( int dvolume );
198 extern void digi_set_volume( int dvolume, int mvolume );
199
200 extern int digi_is_sound_playing(int soundno);
201
202 extern void digi_pause_all();
203 extern void digi_resume_all();
204 extern void digi_stop_all();
205
206 extern void digi_set_max_channels(int n);
207 extern int digi_get_max_channels();
208
209 extern int digi_lomem;
210
211 extern void digi_pause_digi_sounds();
212 extern void digi_resume_digi_sounds();
213
214 int digi_start_sound(int soundnum, fix volume, fix pan, int unknown1, int unknown2, int unknown3, int unknown4);
215 void digi_stop_sound(int channel);
216 void digi_start_sound_queued( short soundnum, fix volume );
217 void digi_play_sample_looping( int soundno, fix max_volume,int loop_start, int loop_end );
218 void digi_stop_looping_sound(void);
219 void digi_change_looping_volume(fix volume);
220
221 #endif