|
|
@ -35,17 +35,17 @@ int total_channels; |
|
|
|
int soundtime; // sample PAIRS
|
|
|
|
int soundtime; // sample PAIRS
|
|
|
|
int paintedtime; // sample PAIRS
|
|
|
|
int paintedtime; // sample PAIRS
|
|
|
|
|
|
|
|
|
|
|
|
convar_t *s_volume; |
|
|
|
static CVAR_DEFINE( s_volume, "volume", "0.7", FCVAR_ARCHIVE, "sound volume" ); |
|
|
|
convar_t *s_musicvolume; |
|
|
|
CVAR_DEFINE( s_musicvolume, "MP3Volume", "1.0", FCVAR_ARCHIVE, "background music volume" ); |
|
|
|
convar_t *s_show; |
|
|
|
static CVAR_DEFINE( s_mixahead, "_snd_mixahead", "0.12", 0, "how much sound to mix ahead of time" ); |
|
|
|
convar_t *s_mixahead; |
|
|
|
static CVAR_DEFINE_AUTO( s_show, "0", FCVAR_ARCHIVE, "show playing sounds" ); |
|
|
|
convar_t *s_lerping; |
|
|
|
CVAR_DEFINE_AUTO( s_lerping, "0", FCVAR_ARCHIVE, "apply interpolation to sound output" ); |
|
|
|
convar_t *s_ambient_level; |
|
|
|
static CVAR_DEFINE( s_ambient_level, "ambient_level", "0.3", FCVAR_ARCHIVE, "volume of environment noises (water and wind)" ); |
|
|
|
convar_t *s_ambient_fade; |
|
|
|
static CVAR_DEFINE( s_ambient_fade, "ambient_fade", "1000", FCVAR_ARCHIVE, "rate of volume fading when client is moving" ); |
|
|
|
convar_t *s_combine_sounds; |
|
|
|
static CVAR_DEFINE_AUTO( s_combine_sounds, "0", FCVAR_ARCHIVE, "combine channels with same sounds" ); |
|
|
|
convar_t *snd_mute_losefocus; |
|
|
|
CVAR_DEFINE_AUTO( snd_mute_losefocus, "1", FCVAR_ARCHIVE, "silence the audio when game window loses focus" ); |
|
|
|
convar_t *s_test; // cvar for testing new effects
|
|
|
|
CVAR_DEFINE_AUTO( s_test, "0", 0, "engine developer cvar for quick testing new features" ); |
|
|
|
convar_t *s_samplecount; |
|
|
|
CVAR_DEFINE_AUTO( s_samplecount, "0", FCVAR_ARCHIVE, "sample count (0 for default value)" ); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
============================================================================= |
|
|
|
============================================================================= |
|
|
@ -68,7 +68,7 @@ float S_GetMasterVolume( void ) |
|
|
|
scale = bound( 0.0f, soundfade.percent / 100.0f, 1.0f ); |
|
|
|
scale = bound( 0.0f, soundfade.percent / 100.0f, 1.0f ); |
|
|
|
scale = 1.0f - scale; |
|
|
|
scale = 1.0f - scale; |
|
|
|
} |
|
|
|
} |
|
|
|
return s_volume->value * scale; |
|
|
|
return s_volume.value * scale; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -945,7 +945,7 @@ void S_UpdateAmbientSounds( void ) |
|
|
|
|
|
|
|
|
|
|
|
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes ); |
|
|
|
leaf = Mod_PointInLeaf( s_listener.origin, cl.worldmodel->nodes ); |
|
|
|
|
|
|
|
|
|
|
|
if( !leaf || !s_ambient_level->value ) |
|
|
|
if( !leaf || !s_ambient_level.value ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for( ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++ ) |
|
|
|
for( ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++ ) |
|
|
|
channels[ambient_channel].sfx = NULL; |
|
|
|
channels[ambient_channel].sfx = NULL; |
|
|
@ -965,18 +965,18 @@ void S_UpdateAmbientSounds( void ) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vol = s_ambient_level->value * leaf->ambient_sound_level[ambient_channel]; |
|
|
|
vol = s_ambient_level.value * leaf->ambient_sound_level[ambient_channel]; |
|
|
|
if( vol < 0 ) vol = 0; |
|
|
|
if( vol < 0 ) vol = 0; |
|
|
|
|
|
|
|
|
|
|
|
// don't adjust volume too fast
|
|
|
|
// don't adjust volume too fast
|
|
|
|
if( chan->master_vol < vol ) |
|
|
|
if( chan->master_vol < vol ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
chan->master_vol += s_listener.frametime * s_ambient_fade->value; |
|
|
|
chan->master_vol += s_listener.frametime * s_ambient_fade.value; |
|
|
|
if( chan->master_vol > vol ) chan->master_vol = vol; |
|
|
|
if( chan->master_vol > vol ) chan->master_vol = vol; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( chan->master_vol > vol ) |
|
|
|
else if( chan->master_vol > vol ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
chan->master_vol -= s_listener.frametime * s_ambient_fade->value; |
|
|
|
chan->master_vol -= s_listener.frametime * s_ambient_fade.value; |
|
|
|
if( chan->master_vol < vol ) chan->master_vol = vol; |
|
|
|
if( chan->master_vol < vol ) chan->master_vol = vol; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1192,7 +1192,7 @@ void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float sy |
|
|
|
ch->s_rawend = soundtime; |
|
|
|
ch->s_rawend = soundtime; |
|
|
|
|
|
|
|
|
|
|
|
// position is changed, synchronization is lost etc
|
|
|
|
// position is changed, synchronization is lost etc
|
|
|
|
if( fabs( ch->oldtime - synctime ) > s_mixahead->value ) |
|
|
|
if( fabs( ch->oldtime - synctime ) > s_mixahead.value ) |
|
|
|
ch->sound_info.loopStart = AVI_TimeToSoundPosition( Avi, synctime * 1000 ); |
|
|
|
ch->sound_info.loopStart = AVI_TimeToSoundPosition( Avi, synctime * 1000 ); |
|
|
|
ch->oldtime = synctime; // keep actual time
|
|
|
|
ch->oldtime = synctime; // keep actual time
|
|
|
|
|
|
|
|
|
|
|
@ -1466,7 +1466,7 @@ void S_UpdateChannels( void ) |
|
|
|
// soundtime - total samples that have been played out to hardware at dmaspeed
|
|
|
|
// soundtime - total samples that have been played out to hardware at dmaspeed
|
|
|
|
// paintedtime - total samples that have been mixed at speed
|
|
|
|
// paintedtime - total samples that have been mixed at speed
|
|
|
|
// endtime - target for samples in mixahead buffer at speed
|
|
|
|
// endtime - target for samples in mixahead buffer at speed
|
|
|
|
endtime = soundtime + s_mixahead->value * SOUND_DMA_SPEED; |
|
|
|
endtime = soundtime + s_mixahead.value * SOUND_DMA_SPEED; |
|
|
|
samps = dma.samples >> 1; |
|
|
|
samps = dma.samples >> 1; |
|
|
|
|
|
|
|
|
|
|
|
if((int)(endtime - soundtime) > samps ) |
|
|
|
if((int)(endtime - soundtime) > samps ) |
|
|
@ -1562,7 +1562,7 @@ void SND_UpdateSound( void ) |
|
|
|
// try to combine static sounds with a previous channel of the same
|
|
|
|
// try to combine static sounds with a previous channel of the same
|
|
|
|
// sound effect so we don't mix five torches every frame
|
|
|
|
// sound effect so we don't mix five torches every frame
|
|
|
|
// g-cont: perfomance option, probably kill stereo effect in most cases
|
|
|
|
// g-cont: perfomance option, probably kill stereo effect in most cases
|
|
|
|
if( i >= MAX_DYNAMIC_CHANNELS && s_combine_sounds->value ) |
|
|
|
if( i >= MAX_DYNAMIC_CHANNELS && s_combine_sounds.value ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// see if it can just use the last one
|
|
|
|
// see if it can just use the last one
|
|
|
|
if( combine && combine->sfx == ch->sfx ) |
|
|
|
if( combine && combine->sfx == ch->sfx ) |
|
|
@ -1602,7 +1602,7 @@ void SND_UpdateSound( void ) |
|
|
|
S_SpatializeRawChannels(); |
|
|
|
S_SpatializeRawChannels(); |
|
|
|
|
|
|
|
|
|
|
|
// debugging output
|
|
|
|
// debugging output
|
|
|
|
if( CVAR_TO_BOOL( s_show )) |
|
|
|
if( s_show.value != 0.0f ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
info.color[0] = 1.0f; |
|
|
|
info.color[0] = 1.0f; |
|
|
|
info.color[1] = 0.6f; |
|
|
|
info.color[1] = 0.6f; |
|
|
@ -1830,17 +1830,17 @@ qboolean S_Init( void ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
s_volume = Cvar_Get( "volume", "0.7", FCVAR_ARCHIVE, "sound volume" ); |
|
|
|
Cvar_RegisterVariable( &s_volume ); |
|
|
|
s_musicvolume = Cvar_Get( "MP3Volume", "1.0", FCVAR_ARCHIVE, "background music volume" ); |
|
|
|
Cvar_RegisterVariable( &s_musicvolume ); |
|
|
|
s_mixahead = Cvar_Get( "_snd_mixahead", "0.12", 0, "how much sound to mix ahead of time" ); |
|
|
|
Cvar_RegisterVariable( &s_mixahead ); |
|
|
|
s_show = Cvar_Get( "s_show", "0", FCVAR_ARCHIVE, "show playing sounds" ); |
|
|
|
Cvar_RegisterVariable( &s_show ); |
|
|
|
s_lerping = Cvar_Get( "s_lerping", "0", FCVAR_ARCHIVE, "apply interpolation to sound output" ); |
|
|
|
Cvar_RegisterVariable( &s_lerping ); |
|
|
|
s_ambient_level = Cvar_Get( "ambient_level", "0.3", FCVAR_ARCHIVE, "volume of environment noises (water and wind)" ); |
|
|
|
Cvar_RegisterVariable( &s_ambient_level ); |
|
|
|
s_ambient_fade = Cvar_Get( "ambient_fade", "1000", FCVAR_ARCHIVE, "rate of volume fading when client is moving" ); |
|
|
|
Cvar_RegisterVariable( &s_ambient_fade ); |
|
|
|
s_combine_sounds = Cvar_Get( "s_combine_channels", "0", FCVAR_ARCHIVE, "combine channels with same sounds" ); |
|
|
|
Cvar_RegisterVariable( &s_combine_sounds ); |
|
|
|
snd_mute_losefocus = Cvar_Get( "snd_mute_losefocus", "1", FCVAR_ARCHIVE, "silence the audio when game window loses focus" ); |
|
|
|
Cvar_RegisterVariable( &snd_mute_losefocus ); |
|
|
|
s_test = Cvar_Get( "s_test", "0", 0, "engine developer cvar for quick testing new features" ); |
|
|
|
Cvar_RegisterVariable( &s_test ); |
|
|
|
s_samplecount = Cvar_Get( "s_samplecount", "0", FCVAR_ARCHIVE, "sample count (0 for default value)" ); |
|
|
|
Cvar_RegisterVariable( &s_samplecount ); |
|
|
|
|
|
|
|
|
|
|
|
Cmd_AddCommand( "play", S_Play_f, "playing a specified sound file" ); |
|
|
|
Cmd_AddCommand( "play", S_Play_f, "playing a specified sound file" ); |
|
|
|
Cmd_AddCommand( "play2", S_Play2_f, "playing a group of specified sound files" ); // nehahra stuff
|
|
|
|
Cmd_AddCommand( "play2", S_Play2_f, "playing a group of specified sound files" ); // nehahra stuff
|
|
|
|