doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ultrasound.h
Go to the documentation of this file.
1 #ifndef _ULTRASOUND_H_
2 #define _ULTRASOUND_H_
3 /*
4  * ultrasound.h - Macros for programming the Gravis Ultrasound
5  * These macros are extremely device dependent
6  * and not portable.
7  */
8 #define COPYING2 Copyright (C) Hannu Savolainen and Dev Mazumdar 1997. All rights reserved.
9 
10 /*
11  * Private events for Gravis Ultrasound (GUS)
12  *
13  * Format:
14  * byte 0 - SEQ_PRIVATE (0xfe)
15  * byte 1 - Synthesizer device number (0-N)
16  * byte 2 - Command (see below)
17  * byte 3 - Voice number (0-31)
18  * bytes 4 and 5 - parameter P1 (unsigned short)
19  * bytes 6 and 7 - parameter P2 (unsigned short)
20  *
21  * Commands:
22  * Each command affects one voice defined in byte 3.
23  * Unused parameters (P1 and/or P2 *MUST* be initialized to zero).
24  * _GUS_NUMVOICES - Sets max. number of concurrent voices (P1=14-31, default 16)
25  * _GUS_VOICESAMPLE- ************ OBSOLETE *************
26  * _GUS_VOICEON - Starts voice (P1=voice mode)
27  * _GUS_VOICEOFF - Stops voice (no parameters)
28  * _GUS_VOICEFADE - Stops the voice smoothly.
29  * _GUS_VOICEMODE - Alters the voice mode, don't start or stop voice (P1=voice mode)
30  * _GUS_VOICEBALA - Sets voice balence (P1, 0=left, 7=middle and 15=right, default 7)
31  * _GUS_VOICEFREQ - Sets voice (sample) playback frequency (P1=Hz)
32  * _GUS_VOICEVOL - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
33  * _GUS_VOICEVOL2 - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
34  * (Like GUS_VOICEVOL but doesn't change the hw
35  * volume. It just updates volume in the voice table).
36  *
37  * _GUS_RAMPRANGE - Sets limits for volume ramping (P1=low volume, P2=high volume)
38  * _GUS_RAMPRATE - Sets the speed for volume ramping (P1=scale, P2=rate)
39  * _GUS_RAMPMODE - Sets the volume ramping mode (P1=ramping mode)
40  * _GUS_RAMPON - Starts volume ramping (no parameters)
41  * _GUS_RAMPOFF - Stops volume ramping (no parameters)
42  * _GUS_VOLUME_SCALE - Changes the volume calculation constants
43  * for all voices.
44  */
45 
46 #define _GUS_NUMVOICES 0x00
47 #define _GUS_VOICESAMPLE 0x01 /* OBSOLETE */
48 #define _GUS_VOICEON 0x02
49 #define _GUS_VOICEOFF 0x03
50 #define _GUS_VOICEMODE 0x04
51 #define _GUS_VOICEBALA 0x05
52 #define _GUS_VOICEFREQ 0x06
53 #define _GUS_VOICEVOL 0x07
54 #define _GUS_RAMPRANGE 0x08
55 #define _GUS_RAMPRATE 0x09
56 #define _GUS_RAMPMODE 0x0a
57 #define _GUS_RAMPON 0x0b
58 #define _GUS_RAMPOFF 0x0c
59 #define _GUS_VOICEFADE 0x0d
60 #define _GUS_VOLUME_SCALE 0x0e
61 #define _GUS_VOICEVOL2 0x0f
62 #define _GUS_VOICE_POS 0x10
63 
64 /*
65  * GUS API macros
66  */
67 
68 #define _GUS_CMD(chn, voice, cmd, p1, p2) \
69  {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\
70  _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\
71  _seqbuf[_seqbufptr+3] = voice;\
72  *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\
73  *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\
74  _SEQ_ADVBUF(8);}
75 
76 #define GUS_NUMVOICES(chn, p1) _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0)
77 #define GUS_VOICESAMPLE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */
78 #define GUS_VOICEON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0)
79 #define GUS_VOICEOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0)
80 #define GUS_VOICEFADE(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0)
81 #define GUS_VOICEMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0)
82 #define GUS_VOICEBALA(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0)
83 #define GUS_VOICEFREQ(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \
84  (p) & 0xffff, ((p) >> 16) & 0xffff)
85 #define GUS_VOICEVOL(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0)
86 #define GUS_VOICEVOL2(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0)
87 #define GUS_RAMPRANGE(chn, voice, low, high) _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high))
88 #define GUS_RAMPRATE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2))
89 #define GUS_RAMPMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0)
90 #define GUS_RAMPON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0)
91 #define GUS_RAMPOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0)
92 #define GUS_VOLUME_SCALE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2))
93 #define GUS_VOICE_POS(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICE_POS, \
94  (p) & 0xffff, ((p) >> 16) & 0xffff)
95 
96 #endif