1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
20 #if defined(PLATFORM_UNIX) && !defined(TARGET_SDL)
21 #define AUDIO_UNIX_NATIVE
24 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE)
25 #define AUDIO_LINUX_IOCTL
28 #if defined(AUDIO_LINUX_IOCTL) || defined(PLATFORM_NETBSD)
29 #define AUDIO_STREAMING_DSP
32 /* values for platform specific sound initialization */
33 #define AUDIO_SAMPLE_RATE_8000 8000
34 #define AUDIO_SAMPLE_RATE_22050 22050
36 #define AUDIO_FRAGMENT_SIZE_512 512
37 #define AUDIO_FRAGMENT_SIZE_1024 1024
38 #define AUDIO_FRAGMENT_SIZE_2048 2048
39 #define AUDIO_FRAGMENT_SIZE_4096 4096
40 #define AUDIO_FRAGMENT_SIZE_32768 32768
42 #define AUDIO_NUM_CHANNELS_MONO 1
43 #define AUDIO_NUM_CHANNELS_STEREO 2
45 #define AUDIO_FORMAT_UNKNOWN (0)
46 #define AUDIO_FORMAT_U8 (1 << 0)
47 #define AUDIO_FORMAT_S16 (1 << 1)
48 #define AUDIO_FORMAT_LE (1 << 2)
49 #define AUDIO_FORMAT_BE (1 << 3)
51 #if defined(AUDIO_UNIX_NATIVE) && !defined(AUDIO_STREAMING_DSP)
52 #define DEFAULT_AUDIO_SAMPLE_RATE AUDIO_SAMPLE_RATE_8000
54 #define DEFAULT_AUDIO_SAMPLE_RATE AUDIO_SAMPLE_RATE_22050
57 #if defined(PLATFORM_HPUX)
58 #define DEFAULT_AUDIO_FRAGMENT_SIZE AUDIO_FRAGMENT_SIZE_32768
59 #elif defined(PLATFORM_WIN32)
60 #define DEFAULT_AUDIO_FRAGMENT_SIZE AUDIO_FRAGMENT_SIZE_1024
62 #define DEFAULT_AUDIO_FRAGMENT_SIZE AUDIO_FRAGMENT_SIZE_512
65 #if defined(TARGET_SDL)
66 #define NUM_MIXER_CHANNELS MIX_CHANNELS
68 #define NUM_MIXER_CHANNELS 8
71 #define MUSIC_CHANNEL 0
72 #define FIRST_SOUND_CHANNEL 1
75 /* values for PlaySound(), StopSound() and friends */
76 #define SND_CTRL_NONE (0)
77 #define SND_CTRL_MUSIC (1 << 0)
78 #define SND_CTRL_LOOP (1 << 1)
79 #define SND_CTRL_FADE (1 << 2)
80 #define SND_CTRL_STOP (1 << 3)
81 #define SND_CTRL_ALL_SOUNDS (1 << 4)
82 #define SND_CTRL_RELOAD_SOUNDS (1 << 5)
83 #define SND_CTRL_RELOAD_MUSIC (1 << 6)
85 #define SND_CTRL_PLAY_SOUND (SND_CTRL_NONE)
86 #define SND_CTRL_PLAY_LOOP (SND_CTRL_LOOP)
87 #define SND_CTRL_PLAY_MUSIC (SND_CTRL_LOOP | SND_CTRL_MUSIC)
89 #define SND_CTRL_FADE_SOUND (SND_CTRL_FADE)
90 #define SND_CTRL_FADE_MUSIC (SND_CTRL_FADE | SND_CTRL_MUSIC)
91 #define SND_CTRL_FADE_ALL (SND_CTRL_FADE | SND_CTRL_ALL_SOUNDS)
93 #define SND_CTRL_STOP_SOUND (SND_CTRL_STOP)
94 #define SND_CTRL_STOP_MUSIC (SND_CTRL_STOP | SND_CTRL_MUSIC)
95 #define SND_CTRL_STOP_ALL (SND_CTRL_STOP | SND_CTRL_ALL_SOUNDS)
97 #define IS_MUSIC(x) ((x).state & SND_CTRL_MUSIC)
98 #define IS_LOOP(x) ((x).state & SND_CTRL_LOOP)
99 #define IS_FADING(x) ((x).state & SND_CTRL_FADE)
100 #define IS_STOPPING(x) ((x).state & SND_CTRL_STOP)
101 #define IS_RELOADING(x) ((x).state & (SND_CTRL_RELOAD_SOUNDS |\
102 SND_CTRL_RELOAD_MUSIC))
103 #define ALL_SOUNDS(x) ((x).state & SND_CTRL_ALL_SOUNDS)
105 #define MAP_NOCONF_MUSIC(x) (-((x) + 1))
106 #define UNMAP_NOCONF_MUSIC(x) MAP_NOCONF_MUSIC(x)
109 #define SOUND_MIN_VOLUME 0
110 #if defined(TARGET_SDL)
111 #define SOUND_MAX_VOLUME SDL_MIX_MAXVOLUME
112 #elif defined(TARGET_ALLEGRO)
113 #define SOUND_MAX_VOLUME 255
115 #define SOUND_MAX_VOLUME 128
118 #define SOUND_MAX_LEFT 0
119 #define SOUND_MAX_RIGHT 255
120 #define SOUND_MAX_LEFT2RIGHT 255
121 #define SOUND_MIDDLE (SOUND_MAX_LEFT2RIGHT / 2)
124 /* general sound functions */
125 void UnixOpenAudio(void);
126 void UnixCloseAudio(void);
128 /* mixer functions */
129 void Mixer_InitChannels(void);
130 void StartMixer(void);
132 /* sound client functions */
135 void PlaySoundStereo(int, int);
136 void PlaySoundLoop(int);
137 void PlaySoundMusic(int);
138 void PlaySoundExt(int, int, int, int);
139 void FadeMusic(void);
141 void FadeSounds(void);
142 void FadeSoundsAndMusic(void);
143 void StopMusic(void);
145 void StopSounds(void);
146 void StopSoundExt(int, int);
148 int getSoundListSize();
149 int getMusicListSize();
150 struct FileInfo *getSoundListEntry(int);
151 struct FileInfo *getMusicListEntry(int);
152 int getSoundListPropertyMappingSize();
153 int getMusicListPropertyMappingSize();
154 struct PropertyMapping *getSoundListPropertyMapping();
155 struct PropertyMapping *getMusicListPropertyMapping();
156 void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
157 char **, char **, char **, char **, char **);
158 void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
159 char **, char **, char **, char **, char **);
160 void InitReloadCustomSounds(char *);
161 void InitReloadCustomMusic(char *);
162 void FreeAllSounds(void);
163 void FreeAllMusic(void);