Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s_volume becomes mastervolume for s_musicvolume #237

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/client/cl_cin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ static void RoQInterrupt(void)
case ZA_SOUND_MONO:
if (!cinTable[currentHandle].silent) {
ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value );
S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value * s_masterVolume->value);
}
break;
case ZA_SOUND_STEREO:
Expand All @@ -1177,7 +1177,7 @@ static void RoQInterrupt(void)
s_rawend = s_soundtime;
}
ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value );
S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value * s_masterVolume->value);
}
break;
case ROQ_QUAD_INFO:
Expand Down
4 changes: 2 additions & 2 deletions code/client/snd_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ static void S_UpdateBackgroundTrack( void ) {
}

// don't bother playing anything if musicvolume is 0
if ( s_musicVolume->value == 0.0f ) {
if ( s_musicVolume->value == 0.0f || s_masterVolume->value == 0.0f ) {
return;
}

Expand Down Expand Up @@ -1377,7 +1377,7 @@ static void S_UpdateBackgroundTrack( void ) {
{
// add to raw buffer
S_Base_RawSamples( fileSamples, s_backgroundStream->info.rate,
s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, s_musicVolume->value );
s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, s_musicVolume->value * s_masterVolume->value );
}
else
{
Expand Down
1 change: 1 addition & 0 deletions code/client/snd_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];

extern cvar_t *s_volume;
extern cvar_t *s_musicVolume;
extern cvar_t *s_masterVolume;
extern cvar_t *s_doppler;
extern cvar_t *s_muteWhenUnfocused;
extern cvar_t *s_muteWhenMinimized;
Expand Down
6 changes: 5 additions & 1 deletion code/client/snd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

cvar_t *s_volume;
cvar_t *s_musicVolume;
cvar_t *s_masterVolume;
cvar_t *s_doppler;
cvar_t *s_muteWhenMinimized;
cvar_t *s_muteWhenUnfocused;
Expand Down Expand Up @@ -412,10 +413,13 @@ void S_Init( void )

s_volume = Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
Cvar_CheckRange( s_volume, "0", "1", CV_FLOAT );
Cvar_SetDescription( s_volume, "Sets master volume for all game audio." );
Cvar_SetDescription( s_volume, "Sets volume for sound effects." );
s_musicVolume = Cvar_Get( "s_musicVolume", "0.25", CVAR_ARCHIVE );
Cvar_CheckRange( s_musicVolume, "0", "1", CV_FLOAT );
Cvar_SetDescription( s_musicVolume, "Sets volume for in-game music only." );
s_masterVolume = Cvar_Get( "s_masterVolume", "1", CVAR_ARCHIVE );
Cvar_CheckRange( s_masterVolume, "0", "1", CV_FLOAT );
Cvar_SetDescription( s_masterVolume, "Sets master volume for all game audio." );
s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE_ND );
Cvar_CheckRange( s_doppler, "0", "1", CV_INTEGER );
Cvar_SetDescription( s_doppler, "Enables doppler effect on moving projectiles." );
Expand Down
2 changes: 1 addition & 1 deletion code/client/snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void S_PaintChannels( int endtime ) {
int sampleOffset;
byte *buffer;

snd_vol = s_volume->value * 255;
snd_vol = (s_volume->value * 255) * s_masterVolume->value;

if ( (!gw_active && !gw_minimized && s_muteWhenUnfocused->integer) || (gw_minimized && s_muteWhenMinimized->integer) ) {
buffer = dma_buffer2;
Expand Down