mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[sound] Add a function to set ambient sounds
This gets ambient sounds (in particular, water and sky) working again for quakeworld after the recent sound changes, and again for nq after I don't know how long.
This commit is contained in:
parent
c72b04a522
commit
330569a3fb
7 changed files with 32 additions and 0 deletions
|
@ -38,6 +38,7 @@ typedef struct snd_render_funcs_s {
|
||||||
void (*init) (void);
|
void (*init) (void);
|
||||||
void (*ambient_off) (void);
|
void (*ambient_off) (void);
|
||||||
void (*ambient_on) (void);
|
void (*ambient_on) (void);
|
||||||
|
void (*set_ambient) (int amb_channel, struct sfx_s *sfx);
|
||||||
void (*static_sound) (struct sfx_s *sfx, vec4f_t origin, float vol, float attenuation);
|
void (*static_sound) (struct sfx_s *sfx, vec4f_t origin, float vol, float attenuation);
|
||||||
void (*start_sound) (int entnum, int entchannel, struct sfx_s *sfx, const vec4f_t, float vol, float attenuation);
|
void (*start_sound) (int entnum, int entchannel, struct sfx_s *sfx, const vec4f_t, float vol, float attenuation);
|
||||||
void (*local_sound) (const char *s);
|
void (*local_sound) (const char *s);
|
||||||
|
|
|
@ -181,6 +181,8 @@ void S_AmbientOff (void);
|
||||||
*/
|
*/
|
||||||
void S_AmbientOn (void);
|
void S_AmbientOn (void);
|
||||||
|
|
||||||
|
void S_SetAmbient (int amb_channel, sfx_t *sfx);
|
||||||
|
|
||||||
/** Link sound engine builtins into the specified progs vm
|
/** Link sound engine builtins into the specified progs vm
|
||||||
\param pr the vm to link the builtins into.
|
\param pr the vm to link the builtins into.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -386,6 +386,8 @@ void SND_AmbientOff (snd_t *snd);
|
||||||
*/
|
*/
|
||||||
void SND_AmbientOn (snd_t *snd);
|
void SND_AmbientOn (snd_t *snd);
|
||||||
|
|
||||||
|
void SND_SetAmbient (snd_t *snd, int amb_channel, sfx_t *sfx);
|
||||||
|
|
||||||
/** Update the sound engine with the client's position and orientation and
|
/** Update the sound engine with the client's position and orientation and
|
||||||
render some sound.
|
render some sound.
|
||||||
\param snd sound system state
|
\param snd sound system state
|
||||||
|
|
|
@ -419,6 +419,15 @@ SND_AmbientOn (snd_t *snd)
|
||||||
snd_ambient = true;
|
snd_ambient = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SND_SetAmbient (snd_t *snd, int amb_channel, sfx_t *sfx)
|
||||||
|
{
|
||||||
|
if (amb_channel < 0 || amb_channel > NUM_AMBIENTS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ambient_sfx[amb_channel] = sfx;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
s_updateAmbientSounds (snd_t *snd, const byte *ambient_sound_level)
|
s_updateAmbientSounds (snd_t *snd, const byte *ambient_sound_level)
|
||||||
{
|
{
|
||||||
|
|
|
@ -418,6 +418,14 @@ s_ambient_on (void)
|
||||||
SND_AmbientOn (&snd);
|
SND_AmbientOn (&snd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
s_set_ambient (int amb_channel, sfx_t *sfx)
|
||||||
|
{
|
||||||
|
if (!sound_started)
|
||||||
|
return;
|
||||||
|
SND_SetAmbient (&snd, amb_channel, sfx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
s_static_sound (sfx_t *sfx, vec4f_t origin, float vol,
|
s_static_sound (sfx_t *sfx, vec4f_t origin, float vol,
|
||||||
float attenuation)
|
float attenuation)
|
||||||
|
@ -551,6 +559,7 @@ static snd_render_funcs_t plugin_info_render_funcs = {
|
||||||
.init = s_init,
|
.init = s_init,
|
||||||
.ambient_off = s_ambient_off,
|
.ambient_off = s_ambient_off,
|
||||||
.ambient_on = s_ambient_on,
|
.ambient_on = s_ambient_on,
|
||||||
|
.set_ambient = s_set_ambient,
|
||||||
.static_sound = s_static_sound,
|
.static_sound = s_static_sound,
|
||||||
.start_sound = s_start_sound,
|
.start_sound = s_start_sound,
|
||||||
.local_sound = s_local_sound,
|
.local_sound = s_local_sound,
|
||||||
|
|
|
@ -148,6 +148,13 @@ S_AmbientOn (void)
|
||||||
snd_render_funcs->ambient_on ();
|
snd_render_funcs->ambient_on ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
S_SetAmbient (int amb_channel, sfx_t *sfx)
|
||||||
|
{
|
||||||
|
if (snd_render_funcs)
|
||||||
|
snd_render_funcs->set_ambient (amb_channel, sfx);
|
||||||
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
S_StaticSound (sfx_t *sfx, vec4f_t origin, float vol, float attenuation)
|
S_StaticSound (sfx_t *sfx, vec4f_t origin, float vol, float attenuation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,6 +129,8 @@ CL_TEnts_Precache (void)
|
||||||
if (!cl_mod_beam) {
|
if (!cl_mod_beam) {
|
||||||
cl_mod_beam = cl_mod_bolt;
|
cl_mod_beam = cl_mod_bolt;
|
||||||
}
|
}
|
||||||
|
S_SetAmbient (AMBIENT_WATER, S_PrecacheSound ("ambience/water1.wav"));
|
||||||
|
S_SetAmbient (AMBIENT_SKY, S_PrecacheSound ("ambience/wind2.wav"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue