XenevaOS
Loading...
Searching...
No Matches
i_sound.h
Go to the documentation of this file.
1//
2// Copyright(C) 1993-1996 Id Software, Inc.
3// Copyright(C) 2005-2014 Simon Howard
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// DESCRIPTION:
16// The not so system specific sound interface.
17//
18
19
20#ifndef __I_SOUND__
21#define __I_SOUND__
22
23#include "doomtype.h"
24
25
26//
27// SoundFX struct.
28//
30
32{
33 // tag name, used for hexen.
34 char *tagname;
35
36 // lump name. If we are running with use_sfx_prefix=true, a
37 // 'DS' (or 'DP' for PC speaker sounds) is prepended to this.
38
39 char name[9];
40
41 // Sfx priority
43
44 // referenced sound if a link
46
47 // pitch if a link
48 int pitch;
49
50 // volume if a link
51 int volume;
52
53 // this is checked every second to see if sound
54 // can be thrown out (if 0, then decrement, if -1,
55 // then throw out, if > 0, then it is in use)
57
58 // lump number of sfx
59 int lumpnum;
60
61 // Maximum number of channels that the sound can be played on
62 // (Heretic)
64
65 // data used by the low level code
67};
68
69//
70// MusicInfo struct.
71//
72typedef struct
73{
74 // up to 6-character name
75 char *name;
76
77 // lump number of music
79
80 // music data
81 void *data;
82
83 // music handle once registered
84 void *handle;
85
87
102
103// Interface for sound modules
104
105typedef struct
106{
107 // List of sound devices that this sound module is used for.
108
111
112 // Initialise sound module
113 // Returns true if successfully initialised
114
115 boolean (*Init)(boolean use_sfx_prefix);
116
117 // Shutdown sound module
118
119 void (*Shutdown)(void);
120
121 // Returns the lump index of the given sound.
122
123 int (*GetSfxLumpNum)(sfxinfo_t *sfxinfo);
124
125 // Called periodically to update the subsystem.
126
127 void (*Update)(void);
128
129 // Update the sound settings on the given channel.
130
131 void (*UpdateSoundParams)(int channel, int vol, int sep);
132
133 // Start a sound on a given channel. Returns the channel id
134 // or -1 on failure.
135
136 int (*StartSound)(sfxinfo_t *sfxinfo, int channel, int vol, int sep);
137
138 // Stop the sound playing on the given channel.
139
140 void (*StopSound)(int channel);
141
142 // Query if a sound is playing on the given channel
143
144 boolean (*SoundIsPlaying)(int channel);
145
146 // Called on startup to precache sound effects (if necessary)
147
148 void (*CacheSounds)(sfxinfo_t *sounds, int num_sounds);
149
151
152void I_InitSound(boolean use_sfx_prefix);
153void I_ShutdownSound(void);
154int I_GetSfxLumpNum(sfxinfo_t *sfxinfo);
155void I_UpdateSound(void);
156void I_UpdateSoundParams(int channel, int vol, int sep);
157int I_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep);
158void I_StopSound(int channel);
159boolean I_SoundIsPlaying(int channel);
160void I_PrecacheSounds(sfxinfo_t *sounds, int num_sounds);
161
162// Interface for music modules
163
164typedef struct
165{
166 // List of sound devices that this music module is used for.
167
170
171 // Initialise the music subsystem
172
173 boolean (*Init)(void);
174
175 // Shutdown the music subsystem
176
177 void (*Shutdown)(void);
178
179 // Set music volume - range 0-127
180
181 void (*SetMusicVolume)(int volume);
182
183 // Pause music
184
185 void (*PauseMusic)(void);
186
187 // Un-pause music
188
189 void (*ResumeMusic)(void);
190
191 // Register a song handle from data
192 // Returns a handle that can be used to play the song
193
194 void *(*RegisterSong)(void *data, int len);
195
196 // Un-register (free) song data
197
198 void (*UnRegisterSong)(void *handle);
199
200 // Play the song
201
202 void (*PlaySong)(void *handle, boolean looping);
203
204 // Stop playing the current song.
205
206 void (*StopSong)(void);
207
208 // Query if music is playing.
209
210 boolean (*MusicIsPlaying)(void);
211
212 // Invoked periodically to poll.
213
214 void (*Poll)(void);
216
217void I_InitMusic(void);
218void I_ShutdownMusic(void);
219void I_SetMusicVolume(int volume);
220void I_PauseSong(void);
221void I_ResumeSong(void);
222void *I_RegisterSong(void *data, int len);
223void I_UnRegisterSong(void *handle);
224void I_PlaySong(void *handle, boolean looping);
225void I_StopSong(void);
226boolean I_MusicIsPlaying(void);
227
228extern int snd_sfxdevice;
229extern int snd_musicdevice;
230extern int snd_samplerate;
231extern int snd_cachesize;
232extern int snd_maxslicetime_ms;
233extern char *snd_musiccmd;
234
235void I_BindSoundVariables(void);
236
237// Sound modules
238
239void I_InitTimidityConfig(void);
240#ifdef FEATURE_SOUND
243#endif
246
247// For OPL module:
248
249extern int opl_io_port;
250
251// For native music module:
252
253extern char *timidity_cfg_path;
254
255#endif
256
boolean
Definition doomtype.h:74
sound_module_t DG_sound_module
Definition i_dgsound.c:345
music_module_t DG_music_module
Definition i_dgsound.c:404
int snd_samplerate
Definition i_sound.c:39
void I_StopSong(void)
Definition i_sound.c:374
char * snd_musiccmd
Definition i_sound.c:53
void I_SetMusicVolume(int volume)
Definition i_sound.c:322
snddevice_t
Definition i_sound.h:89
@ SNDDEVICE_GUS
Definition i_sound.h:95
@ SNDDEVICE_SOUNDCANVAS
Definition i_sound.h:97
@ SNDDEVICE_PCSPEAKER
Definition i_sound.h:91
@ SNDDEVICE_ADLIB
Definition i_sound.h:92
@ SNDDEVICE_WAVEBLASTER
Definition i_sound.h:96
@ SNDDEVICE_GENMIDI
Definition i_sound.h:98
@ SNDDEVICE_CD
Definition i_sound.h:100
@ SNDDEVICE_AWE32
Definition i_sound.h:99
@ SNDDEVICE_NONE
Definition i_sound.h:90
@ SNDDEVICE_PAS
Definition i_sound.h:94
@ SNDDEVICE_SB
Definition i_sound.h:93
void I_InitTimidityConfig(void)
Definition dummy.c:45
void I_UnRegisterSong(void *handle)
Definition i_sound.c:358
int snd_sfxdevice
Definition i_sound.c:61
void I_PrecacheSounds(sfxinfo_t *sounds, int num_sounds)
Definition i_sound.c:301
void I_ShutdownMusic(void)
Definition i_sound.c:317
char * timidity_cfg_path
boolean I_MusicIsPlaying(void)
Definition i_sound.c:382
int opl_io_port
int snd_cachesize
Definition i_sound.c:44
int I_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep)
Definition i_sound.c:268
int snd_musicdevice
Definition i_sound.c:60
boolean I_SoundIsPlaying(int channel)
Definition i_sound.c:289
sound_module_t sound_pcsound_module
void I_InitMusic(void)
Definition i_sound.c:309
void I_InitSound(boolean use_sfx_prefix)
Definition i_sound.c:144
void I_ResumeSong(void)
Definition i_sound.c:338
int snd_maxslicetime_ms
Definition i_sound.c:49
void I_PlaySong(void *handle, boolean looping)
Definition i_sound.c:366
music_module_t music_opl_module
void * I_RegisterSong(void *data, int len)
Definition i_sound.c:346
int I_GetSfxLumpNum(sfxinfo_t *sfxinfo)
Definition i_sound.c:213
void I_PauseSong(void)
Definition i_sound.c:330
void I_StopSound(int channel)
Definition i_sound.c:281
void I_ShutdownSound(void)
Definition i_sound.c:200
void I_UpdateSound(void)
Definition i_sound.c:225
void I_BindSoundVariables(void)
Definition i_sound.c:395
void I_UpdateSoundParams(int channel, int vol, int sep)
Definition i_sound.c:259
size_t len
Definition initial.c:23
void * data
Definition kthread.h:30
Definition i_sound.h:165
snddevice_t * sound_devices
Definition i_sound.h:168
int num_sound_devices
Definition i_sound.h:169
Definition i_sound.h:73
int lumpnum
Definition i_sound.h:78
char * name
Definition i_sound.h:75
void * data
Definition i_sound.h:81
void * handle
Definition i_sound.h:84
Definition i_sound.h:32
int usefulness
Definition i_sound.h:56
char name[9]
Definition i_sound.h:39
int priority
Definition i_sound.h:42
int lumpnum
Definition i_sound.h:59
int volume
Definition i_sound.h:51
char * tagname
Definition i_sound.h:34
void * driver_data
Definition i_sound.h:66
int numchannels
Definition i_sound.h:63
int pitch
Definition i_sound.h:48
sfxinfo_t * link
Definition i_sound.h:45
Definition i_sound.h:106
snddevice_t * sound_devices
Definition i_sound.h:109
int num_sound_devices
Definition i_sound.h:110
uint8_t channel
Definition wifi.cpp:795