mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Implement a master volume control that functions separately from the sound effect and music volume controls. This is important because it allows waveform based music (like the SC-55 music pack, etc.) to play back at a louder volume than the sound effects if the end user so desires.
git-svn-id: https://svn.eduke32.com/eduke32@3993 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e83927c2f8
commit
3391de39be
8 changed files with 51 additions and 36 deletions
|
@ -188,6 +188,7 @@ void CONFIG_SetDefaults(void)
|
|||
ud.config.AmbienceToggle = 1;
|
||||
ud.config.AutoAim = 1;
|
||||
ud.config.FXDevice = 0;
|
||||
ud.config.MasterVolume = 255;
|
||||
ud.config.FXVolume = 225;
|
||||
#if defined(_WIN32)
|
||||
ud.config.MixRate = 44100;
|
||||
|
|
|
@ -8685,7 +8685,7 @@ void G_HandleLocalKeys(void)
|
|||
// FIXME: http://forums.duke4.net/topic/6308-eduke32-crashed-when-press-altprintscreen/
|
||||
// HINT: keeping temp-sounding variables like "i" live for
|
||||
// a long time surely is recipe for disaster :/.
|
||||
FX_PlayAuto3D((char *)RTS_GetSound(i-1),RTS_SoundLength(i-1),0,0,0,255,-i);
|
||||
FX_PlayAuto3D((char *)RTS_GetSound(i-1),RTS_SoundLength(i-1),0,0,FX_VOLUME(1),255,-i);
|
||||
|
||||
g_RTSPlaying = 7;
|
||||
#ifndef NETCODE_DISABLE
|
||||
|
|
|
@ -188,6 +188,7 @@ typedef struct {
|
|||
//
|
||||
int32_t FXDevice;
|
||||
int32_t MusicDevice;
|
||||
int32_t MasterVolume;
|
||||
int32_t FXVolume;
|
||||
int32_t MusicVolume;
|
||||
int32_t SoundToggle;
|
||||
|
|
|
@ -4465,9 +4465,8 @@ cheat_for_port_credits2:
|
|||
const char *opts[] =
|
||||
{
|
||||
"Sound",
|
||||
"Sound volume",
|
||||
"-",
|
||||
"Music",
|
||||
"Master volume",
|
||||
"Effects volume",
|
||||
"Music volume",
|
||||
"-",
|
||||
"Playback sampling rate",
|
||||
|
@ -4495,7 +4494,7 @@ cheat_for_port_credits2:
|
|||
io++;
|
||||
}
|
||||
|
||||
onbar = (probey == 1 || probey == 3);
|
||||
onbar = (probey >=1 && probey <= 4);
|
||||
x = probesm(margin,yy+5,0,io);
|
||||
|
||||
if (x == -1)
|
||||
|
@ -4545,25 +4544,14 @@ cheat_for_port_credits2:
|
|||
S_ClearSoundLocks();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mgametextpal(d,yy, ud.config.SoundToggle ? "On" : "Off", MENUHIGHLIGHT(io), 0);
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0);
|
||||
l = ud.config.FXVolume;
|
||||
sliderbar(1,d+8,yy+7, &ud.config.FXVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
|
||||
if (l != ud.config.FXVolume)
|
||||
FX_SetVolume((int16_t) ud.config.FXVolume);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
||||
if (ud.config.MusicDevice >= 0)
|
||||
{
|
||||
i = ud.config.MusicToggle;
|
||||
modval(0,1,(int32_t *)&ud.config.MusicToggle,1,probey==io);
|
||||
if (x==io)
|
||||
ud.config.MusicToggle = 1-ud.config.MusicToggle;
|
||||
ud.config.MusicToggle = ud.config.SoundToggle;
|
||||
|
||||
if (i != ud.config.MusicToggle)
|
||||
{
|
||||
if (ud.config.MusicToggle == 0) S_PauseMusic(1);
|
||||
|
@ -4572,23 +4560,44 @@ cheat_for_port_credits2:
|
|||
if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME)
|
||||
{
|
||||
if (MapInfo[g_musicIndex].musicfn != NULL)
|
||||
S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0],g_musicIndex);
|
||||
S_PlayMusic(&MapInfo[g_musicIndex].musicfn[0], g_musicIndex);
|
||||
}
|
||||
else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS);
|
||||
else S_PlayMusic(&EnvMusicFilename[0][0], MAXVOLUMES*MAXLEVELS);
|
||||
|
||||
S_PauseMusic(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
mgametextpal(d,yy, ud.config.MusicToggle ? "On" : "Off", MENUHIGHLIGHT(io), 0);
|
||||
|
||||
mgametextpal(d,yy, ud.config.SoundToggle ? "On" : "Off", MENUHIGHLIGHT(io), 0);
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0);
|
||||
l = ud.config.MasterVolume;
|
||||
sliderbar(1, d+8, yy+7, &ud.config.MasterVolume, 15, probey==io, enabled ? MENUHIGHLIGHT(io) : UNSELMENUSHADE, !enabled, 0, 255);
|
||||
if (l != ud.config.MasterVolume)
|
||||
{
|
||||
FX_SetVolume((int16_t) ud.config.MasterVolume);
|
||||
S_MusicVolume((int16_t) MASTER_VOLUME(ud.config.MusicVolume));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
enabled = (ud.config.SoundToggle && ud.config.FXDevice >= 0);
|
||||
sliderbar(1,d+8,yy+7, &ud.config.FXVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,1,255);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
enabled = (ud.config.MusicToggle && ud.config.MusicDevice >= 0);
|
||||
l = ud.config.MusicVolume;
|
||||
sliderbar(1,d+8,yy+7, &ud.config.MusicVolume,15,probey==io,enabled?MENUHIGHLIGHT(io):UNSELMENUSHADE,!enabled,0,255);
|
||||
if (l != ud.config.MusicVolume)
|
||||
S_MusicVolume((int16_t) ud.config.MusicVolume);
|
||||
S_MusicVolume((int16_t) MASTER_VOLUME(ud.config.MusicVolume));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
|
|
|
@ -684,8 +684,8 @@ void Net_ParsePacketCommon(uint8_t *pbuf, int32_t packbufleng, int32_t serverpac
|
|||
|
||||
if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4))
|
||||
break;
|
||||
|
||||
FX_PlayAuto3D((char *)RTS_GetSound(pbuf[1]-1),RTS_SoundLength(pbuf[1]-1),FX_ONESHOT,0,0,0,255,-pbuf[1]);
|
||||
|
||||
FX_PlayAuto3D((char *)RTS_GetSound(pbuf[1]-1),RTS_SoundLength(pbuf[1]-1),FX_ONESHOT,0,0,FX_VOLUME(1),255,-pbuf[1]);
|
||||
g_RTSPlaying = 7;
|
||||
break;
|
||||
|
||||
|
|
|
@ -1497,7 +1497,8 @@ int32_t registerosdcommands(void)
|
|||
{ "snd_ambience", "enables/disables ambient sounds", (void *)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 1 },
|
||||
{ "snd_duketalk", "enables/disables Duke's speech", (void *)&ud.config.VoiceToggle, CVAR_INT, 0, 5 },
|
||||
{ "snd_enabled", "enables/disables sound effects", (void *)&ud.config.SoundToggle, CVAR_BOOL, 0, 1 },
|
||||
{ "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 0, 255 },
|
||||
{ "snd_mastervolume", "master volume for sound system", (void *)&ud.config.MasterVolume, CVAR_INT, 0, 255 },
|
||||
{ "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 1, 255 },
|
||||
{ "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 },
|
||||
{ "snd_numbits", "sound bits", (void *)&ud.config.NumBits, CVAR_INT, 8, 16 },
|
||||
{ "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 },
|
||||
|
|
|
@ -87,7 +87,7 @@ void S_SoundStartup(void)
|
|||
g_soundlocks[i] = 199;
|
||||
}
|
||||
|
||||
FX_SetVolume(ud.config.FXVolume);
|
||||
FX_SetVolume(ud.config.MasterVolume);
|
||||
FX_SetReverseStereo(ud.config.ReverseStereo);
|
||||
FX_SetCallBack(S_Callback);
|
||||
FX_SetPrintf(initprintf);
|
||||
|
@ -118,7 +118,7 @@ void S_MusicStartup(void)
|
|||
|
||||
if (MUSIC_Init(ud.config.MusicDevice, 0) == MUSIC_Ok || MUSIC_Init((ud.config.MusicDevice = 0), 0) == MUSIC_Ok)
|
||||
{
|
||||
MUSIC_SetVolume(ud.config.MusicVolume);
|
||||
MUSIC_SetVolume(MASTER_VOLUME(ud.config.MusicVolume));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
|
|||
}
|
||||
else
|
||||
{
|
||||
int32_t mvol = ud.config.MusicVolume;
|
||||
int32_t mvol = MASTER_VOLUME(ud.config.MusicVolume);
|
||||
MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0,
|
||||
0, mvol, mvol, mvol,
|
||||
FX_MUSIC_PRIORITY, MUSIC_ID);
|
||||
|
@ -663,11 +663,11 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
|
|||
g_soundlocks[num]--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (repeatp && !ambsfxp)
|
||||
{
|
||||
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
|
||||
pitch, sndist>>6, sndist>>6, 0, // XXX: why is 'right' 0?
|
||||
pitch, FX_VOLUME(sndist>>6), FX_VOLUME(sndist>>6), 0, // XXX: why is 'right' 0?
|
||||
g_sounds[num].pr, (num * MAXSOUNDINSTANCES) + j);
|
||||
}
|
||||
else
|
||||
|
@ -675,7 +675,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
|
|||
// Ambient MUSICANDSFX always start playing using the 3D routines!
|
||||
voice = FX_PlayAuto3D(g_sounds[num].ptr, g_sounds[num].soundsiz,
|
||||
repeatp ? FX_LOOP : FX_ONESHOT,
|
||||
pitch, sndang>>4, sndist>>6,
|
||||
pitch, sndang>>4, FX_VOLUME(sndist>>6),
|
||||
g_sounds[num].pr, (num * MAXSOUNDINSTANCES) + j);
|
||||
}
|
||||
}
|
||||
|
@ -740,11 +740,11 @@ int32_t S_PlaySound(int32_t num)
|
|||
|
||||
if (g_sounds[num].m&1)
|
||||
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
|
||||
pitch, LOUDESTVOLUME, LOUDESTVOLUME, LOUDESTVOLUME,
|
||||
pitch,FX_VOLUME(LOUDESTVOLUME), FX_VOLUME(LOUDESTVOLUME), FX_VOLUME(LOUDESTVOLUME),
|
||||
g_sounds[num].soundsiz, (num * MAXSOUNDINSTANCES) + j);
|
||||
else
|
||||
voice = FX_PlayAuto3D(g_sounds[num].ptr, g_sounds[num].soundsiz, FX_ONESHOT,
|
||||
pitch, 0, 255-LOUDESTVOLUME,
|
||||
pitch, 0, FX_VOLUME(255-LOUDESTVOLUME),
|
||||
g_sounds[num].pr, (num * MAXSOUNDINSTANCES) + j);
|
||||
|
||||
if (voice <= FX_Ok)
|
||||
|
@ -881,7 +881,7 @@ void S_Update(void)
|
|||
g_numEnvSoundsPlaying++;
|
||||
|
||||
// AMBIENT_SOUND
|
||||
FX_Pan3D(g_sounds[num].SoundOwner[k].voice, sndang>>4, sndist>>6);
|
||||
FX_Pan3D(g_sounds[num].SoundOwner[k].voice, sndang>>4, FX_VOLUME(sndist>>6));
|
||||
g_sounds[num].SoundOwner[k].sndist = sndist>>6;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define LOUDESTVOLUME 150
|
||||
#define MUSIC_ID -65536
|
||||
|
||||
#define FX_VOLUME(x) scale(x, 255, ud.config.FXVolume)
|
||||
#define MASTER_VOLUME(x) scale(ud.config.MasterVolume, x, 255)
|
||||
|
||||
struct audioenumdev
|
||||
{
|
||||
char *def;
|
||||
|
|
Loading…
Reference in a new issue