fixed code to compile with current gcc and 64-bit systems
[rocksndiamonds.git] / src / sound.h
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  ©1995 Artsoft Development                               *
5 *        Holger Schemel                                    *
6 *        33659 Bielefeld-Senne                             *
7 *        Telefon: (0521) 493245                            *
8 *        eMail: aeglos@valinor.owl.de                      *
9 *               aeglos@uni-paderborn.de                    *
10 *               q99492@pbhrzx.uni-paderborn.de             *
11 *----------------------------------------------------------*
12 *  sound.c                                                 *
13 *                                                          *
14 *  Letzte Aenderung: 15.06.1995                            *
15 ***********************************************************/
16
17 #ifndef SOUND_H
18 #define SOUND_H
19
20 #include "main.h"
21 #include <math.h>
22
23 #ifdef linux
24 #include <linux/soundcard.h>
25 #ifndef VOXWARE
26 #define VOXWARE
27 #endif
28 /* where is the right declaration for 'ioctl'? */
29 extern void ioctl(int, int, void *);
30 #endif
31
32 #define SND_BLOCKSIZE 4096
33
34 #ifdef _HPUX_SOURCE
35 #include <sys/audio.h>
36 #undef  SND_BLOCKSIZE
37 #define SND_BLOCKSIZE 32768
38 #define HPUX_AUDIO
39 #endif /* _HPUX_SOURCE */
40
41 #define MAX_SOUNDS_PLAYING      16
42
43 /* some values for PlaySound(), StopSound() and friends */
44 #define PSND_SILENCE            0
45 #define PSND_MAX_VOLUME_BITS    7
46 #define PSND_MIN_VOLUME         0
47 #define PSND_MAX_VOLUME         (1 << PSND_MAX_VOLUME_BITS)
48 #define PSND_NO_LOOP            0
49 #define PSND_LOOP               1
50 #define PSND_MIDDLE             0
51 #define PSND_MAX_STEREO_BITS    7
52 #define PSND_MAX_STEREO         (1 << PSND_MAX_STEREO_BITS)
53 #define PSND_MAX_LEFT           (-PSND_MAX_STEREO)
54 #define PSND_MAX_RIGHT          (+PSND_MAX_STEREO)
55 #define PSND_MAX_LEFT2RIGHT_BITS (PSND_MAX_STEREO_BITS+1)
56 #define PSND_MAX_LEFT2RIGHT     (1 << PSND_MAX_LEFT2RIGHT_BITS)
57
58 #define SSND_FADE_SOUND         (1<<0)
59 #define SSND_FADE_ALL_SOUNDS    (1<<1)
60 #define SSND_FADING(x)          (x & (SSND_FADE_SOUND | SSND_FADE_ALL_SOUNDS))
61 #define SSND_STOP_SOUND         (1<<2)
62 #define SSND_STOP_ALL_SOUNDS    (1<<3)
63 #define SSND_STOPPING(x)        (x & (SSND_STOP_SOUND | SSND_STOP_ALL_SOUNDS))
64 #define SSND_ALL(x)             (x&(SSND_FADE_ALL_SOUNDS|SSND_STOP_ALL_SOUNDS))
65
66 #define TRUE    1
67 #define FALSE   0
68
69 /* settings for sound path, sound device, etc. */
70 #ifndef SND_PATH
71 #define SND_PATH        "./sounds"
72 #endif
73
74 #define DEV_AUDIO       "/dev/audio"
75 #define DEV_DSP         "/dev/dsp"
76
77 #ifdef  VOXWARE
78 #define SOUND_DEVICE    DEV_DSP
79 #else
80 #define SOUND_DEVICE    DEV_AUDIO
81 #endif
82
83 #define SOUND_OFF       0
84 #define SOUND_AVAILABLE 1
85
86 #ifdef NO_SOUNDS
87 #define SOUND_STATUS    SOUND_OFF
88 #else
89 #define SOUND_STATUS    SOUND_AVAILABLE
90 #endif
91
92 /* function from "misc.c" */
93 unsigned int be2int(unsigned int *);
94
95 /* sound server functions */
96 void SoundServer(void);
97 void SoundServer_InsertNewSound(struct SoundControl);
98 void SoundServer_StopSound(int);
99 void SoundServer_StopAllSounds(void);
100 void HPUX_Audio_Control(void);
101 unsigned char linear_to_ulaw(int);
102 int ulaw_to_linear(unsigned char);
103
104 /* application functions */
105 BOOL LoadSound(struct SoundInfo *);
106 void PlaySound(int);
107 void PlaySoundStereo(int, int);
108 void PlaySoundLoop(int);
109 void PlaySoundExt(int, int, int, BOOL);
110 void FadeSound(int);
111 void FadeSounds(void);
112 void StopSound(int);
113 void StopSounds(void);
114 void StopSoundExt(int, int);
115 void FreeSounds(int);
116
117 #endif