mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 06:53:40 +00:00
Added a master volume setting.
This commit is contained in:
parent
baf5ebd1ce
commit
407983749a
7 changed files with 25 additions and 3 deletions
|
@ -98,6 +98,7 @@ extern int SinglePlayerClass[/*MAXPLAYERS*/];
|
|||
// -------------------------
|
||||
// Internal parameters for sound rendering.
|
||||
|
||||
EXTERN_CVAR (Float, snd_mastervolume) // maximum master volume
|
||||
EXTERN_CVAR (Float, snd_sfxvolume) // maximum volume for sound
|
||||
EXTERN_CVAR (Float, snd_musicvolume) // maximum volume for music
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ CUSTOM_CVAR (Float, snd_musicvolume, 0.5f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
// Set general music volume.
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetMusicVolume(clamp<float>(self * relative_volume, 0, 1));
|
||||
GSnd->SetMusicVolume(clamp<float>(self * relative_volume * snd_mastervolume, 0, 1));
|
||||
}
|
||||
// For music not implemented through the digital sound system,
|
||||
// let them know about the change.
|
||||
|
|
|
@ -543,4 +543,5 @@ MusInfo *SndFile_OpenSong(FileReader &fr);
|
|||
extern MusInfo *currSong;
|
||||
void MIDIDeviceChanged(int newdev, bool force = false);
|
||||
|
||||
EXTERN_CVAR (Float, snd_mastervolume)
|
||||
EXTERN_CVAR (Float, snd_musicvolume)
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "stats.h"
|
||||
|
||||
EXTERN_CVAR (Float, snd_sfxvolume)
|
||||
EXTERN_CVAR (Float, snd_musicvolume)
|
||||
CVAR (Int, snd_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Int, snd_hrtf, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
@ -76,6 +77,23 @@ void I_CloseSound ();
|
|||
// SFX API
|
||||
//
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CVAR snd_mastervolume
|
||||
//
|
||||
// Maximum volume of all audio
|
||||
//==========================================================================
|
||||
|
||||
CUSTOM_CVAR(Float, snd_mastervolume, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (self < 0.f)
|
||||
self = 0.f;
|
||||
else if (self > 1.f)
|
||||
self = 1.f;
|
||||
snd_sfxvolume.Callback();
|
||||
snd_musicvolume.Callback();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CVAR snd_sfxvolume
|
||||
|
@ -91,7 +109,7 @@ CUSTOM_CVAR (Float, snd_sfxvolume, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOIN
|
|||
self = 1.f;
|
||||
else if (GSnd != NULL)
|
||||
{
|
||||
GSnd->SetSfxVolume (self);
|
||||
GSnd->SetSfxVolume (self * snd_mastervolume);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ void MIDIStreamer::MusicVolumeChanged()
|
|||
{
|
||||
if (MIDI != NULL && MIDI->FakeVolume())
|
||||
{
|
||||
float realvolume = clamp<float>(snd_musicvolume * relative_volume, 0.f, 1.f);
|
||||
float realvolume = clamp<float>(snd_musicvolume * relative_volume * snd_mastervolume, 0.f, 1.f);
|
||||
Volume = clamp<uint32_t>((uint32_t)(realvolume * 65535.f), 0, 65535);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2201,6 +2201,7 @@ CMPTMNU_CHECKSWITCHRANGE = "Enable buggy CheckSwitchRange behavior";
|
|||
|
||||
// Sound Options
|
||||
SNDMNU_TITLE = "Sound Options";
|
||||
SNDMNU_MASTERVOLUME = "Master volume";
|
||||
SNDMNU_SFXVOLUME = "Sounds volume";
|
||||
SNDMNU_MENUVOLUME = "Menu volume";
|
||||
SNDMNU_MUSICVOLUME = "Music volume";
|
||||
|
|
|
@ -1741,6 +1741,7 @@ OptionValue MidiDevices
|
|||
OptionMenu SoundOptions protected
|
||||
{
|
||||
Title "$SNDMNU_TITLE"
|
||||
Slider "$SNDMNU_MASTERVOLUME", "snd_mastervolume", 0, 1, 0.05, 2
|
||||
Slider "$SNDMNU_SFXVOLUME", "snd_sfxvolume", 0, 1, 0.05, 2
|
||||
Slider "$SNDMNU_MENUVOLUME", "snd_menuvolume", 0, 1, 0.05, 2
|
||||
Slider "$SNDMNU_MUSICVOLUME", "snd_musicvolume", 0, 1, 0.05, 2
|
||||
|
|
Loading…
Reference in a new issue