ref: d54a1ab430987fb6bda3c05ee2db2e9d012a6341
parent: e920b33fe51d5f129935ae7d8bfc85bf37263e3d
author: Simon Howard <[email protected]>
date: Thu Mar 23 12:43:15 EST 2006
Separate variables for config file volume levels and sound API internal volume levels (this is how the Vanilla code behaves). Fixes sound behavior on level 8! Subversion-branch: /trunk/chocolate-doom Subversion-revision: 429
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: d_main.c 419 2006-03-15 18:52:31Z fraggle $
+// $Id: d_main.c 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -184,7 +184,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: d_main.c 419 2006-03-15 18:52:31Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 429 2006-03-23 17:43:15Z fraggle $";
#define BGCOLOR 7
#define FGCOLOR 8
@@ -1649,7 +1649,7 @@
PrintGameVersion();
printf (DEH_String("S_Init: Setting up sound.\n"));
- S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );
+ S_Init (sfxVolume * 8, musicVolume * 8);
printf (DEH_String("HU_Init: Setting up heads up display.\n"));
HU_Init ();
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: doomstat.h 388 2006-02-24 19:14:22Z fraggle $
+// $Id: doomstat.h 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -105,13 +105,12 @@
// but are not (yet) supported with Linux
// (e.g. no sound volume adjustment with menu.
-// These are not used, but should be (menu).
// From m_menu.c:
// Sound FX volume has default, 0 - 15
// Music volume has default, 0 - 15
// These are multiplied by 8.
-extern int snd_SfxVolume; // maximum volume for sound
-extern int snd_MusicVolume; // maximum volume for music
+extern int sfxVolume;
+extern int musicVolume;
// Current music/sfx card - index useless
// w/o a reference LUT in a sound module.
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_sound.c 426 2006-03-18 23:24:04Z fraggle $
+// $Id: i_sound.c 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -128,7 +128,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_sound.c 426 2006-03-18 23:24:04Z fraggle $";
+rcsid[] = "$Id: i_sound.c 429 2006-03-23 17:43:15Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -348,12 +348,7 @@
void I_SetSfxVolume(int volume)
{
- // Identical to DOS.
- // Basically, this should propagate
- // the menu/config file setting
- // to the state variable used in
- // the mixing.
- snd_SfxVolume = volume;
+ // Unused
}
@@ -501,8 +496,8 @@
if (!sound_initialised)
return;
- left = ((254 - sep) * vol) / 15;
- right = ((sep) * vol) / 15;
+ left = ((254 - sep) * vol) / 127;
+ right = ((sep) * vol) / 127;
Mix_SetPanning(handle, left, right);
}
@@ -586,6 +581,7 @@
}
static boolean musicpaused = false;
+static int currentMusicVolume;
//
// SDL_mixer's native MIDI music playing does not pause properly.
@@ -599,7 +595,7 @@
if (musicpaused)
vol = 0;
else
- vol = (snd_MusicVolume * MIX_MAX_VOLUME) / 15;
+ vol = (currentMusicVolume * MIX_MAX_VOLUME) / 127;
Mix_VolumeMusic(vol);
}
@@ -608,7 +604,7 @@
void I_SetMusicVolume(int volume)
{
// Internal state variable.
- snd_MusicVolume = volume;
+ currentMusicVolume = volume;
UpdateMusicVolume();
}
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_menu.c 328 2006-01-22 23:48:00Z fraggle $
+// $Id: m_menu.c 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -78,7 +78,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_menu.c 328 2006-01-22 23:48:00Z fraggle $";
+rcsid[] = "$Id: m_menu.c 429 2006-03-23 17:43:15Z fraggle $";
#include <stdlib.h>
#include <ctype.h>
@@ -878,10 +878,10 @@
V_DrawPatchDirect (60,38,0,W_CacheLumpName(DEH_String("M_SVOL"),PU_CACHE));
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1),
- 16,snd_SfxVolume);
+ 16,sfxVolume);
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1),
- 16,snd_MusicVolume);
+ 16,musicVolume);
}
void M_Sound(int choice)
@@ -894,16 +894,16 @@
switch(choice)
{
case 0:
- if (snd_SfxVolume)
- snd_SfxVolume--;
+ if (sfxVolume)
+ sfxVolume--;
break;
case 1:
- if (snd_SfxVolume < 15)
- snd_SfxVolume++;
+ if (sfxVolume < 15)
+ sfxVolume++;
break;
}
- S_SetSfxVolume(snd_SfxVolume /* *8 */);
+ S_SetSfxVolume(sfxVolume * 8);
}
void M_MusicVol(int choice)
@@ -911,16 +911,16 @@
switch(choice)
{
case 0:
- if (snd_MusicVolume)
- snd_MusicVolume--;
+ if (musicVolume)
+ musicVolume--;
break;
case 1:
- if (snd_MusicVolume < 15)
- snd_MusicVolume++;
+ if (musicVolume < 15)
+ musicVolume++;
break;
}
- S_SetMusicVolume(snd_MusicVolume /* *8 */);
+ S_SetMusicVolume(musicVolume * 8);
}
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_misc.c 367 2006-02-15 12:57:58Z fraggle $
+// $Id: m_misc.c 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -106,7 +106,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_misc.c 367 2006-02-15 12:57:58Z fraggle $";
+rcsid[] = "$Id: m_misc.c 429 2006-03-23 17:43:15Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -333,8 +333,8 @@
static default_t doom_defaults_list[] =
{
{"mouse_sensitivity", &mouseSensitivity},
- {"sfx_volume",&snd_SfxVolume},
- {"music_volume",&snd_MusicVolume},
+ {"sfx_volume",&sfxVolume},
+ {"music_volume",&musicVolume},
{"show_messages",&showMessages},
{"key_right",&key_right, DEFAULT_KEY},
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: s_sound.c 318 2006-01-22 21:20:20Z fraggle $
+// $Id: s_sound.c 429 2006-03-23 17:43:15Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -67,7 +67,7 @@
static const char
-rcsid[] = "$Id: s_sound.c 318 2006-01-22 21:20:20Z fraggle $";
+rcsid[] = "$Id: s_sound.c 429 2006-03-23 17:43:15Z fraggle $";
@@ -153,14 +153,15 @@
// the set of channels available
static channel_t* channels;
-// These are not used, but should be (menu).
// Maximum volume of a sound effect.
// Internal default is max out of 0-15.
-int snd_SfxVolume = 8;
+int sfxVolume = 8;
-// Maximum volume of music. Useless so far.
-int snd_MusicVolume = 8;
+// Maximum volume of music.
+int musicVolume = 8;
+// Internal volume level, ranging from 0-127
+static int snd_SfxVolume;
// whether songs are mus_paused
@@ -654,7 +655,6 @@
I_SetMusicVolume(127);
I_SetMusicVolume(volume);
- snd_MusicVolume = volume;
}