mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Rework volume control to not completely suck
git-svn-id: https://svn.eduke32.com/eduke32@7122 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6513d9f3e3
commit
ed2f9f247b
16 changed files with 66 additions and 72 deletions
|
@ -55,6 +55,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#define MIX_VOLUME(volume) ((max(0, min((volume), 255)) * (MV_MAXVOLUME + 1)) >> 8)
|
||||
|
||||
extern float MV_GlobalVolume;
|
||||
|
||||
template <typename T>
|
||||
static inline conditional_t< is_signed<T>::value, make_unsigned_t<T>, make_signed_t<T> > FLIP_SIGN(T src)
|
||||
{
|
||||
|
@ -196,7 +198,7 @@ void MV_PlayVoice(VoiceNode *voice);
|
|||
VoiceNode *MV_AllocVoice(int32_t priority);
|
||||
|
||||
void MV_SetVoiceMixMode(VoiceNode *voice);
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right);
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume);
|
||||
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int32_t pitchoffset);
|
||||
|
||||
int32_t MV_GetVorbisPosition(VoiceNode *voice);
|
||||
|
|
|
@ -634,9 +634,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
|
|||
voice->FixedPointBufferSize = (voice->RateScale * MV_MIXBUFFERSIZE) - voice->RateScale;
|
||||
MV_SetVoiceMixMode(voice);
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return voice->handle;
|
||||
|
|
|
@ -411,10 +411,9 @@ int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL;
|
||||
voice->LoopEnd = NULL;
|
||||
voice->LoopSize = loopend > 0 ? loopend - loopstart + 1 : blocklen;
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoicePitch(voice, format.nSamplesPerSec, pitchoffset);
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return voice->handle;
|
||||
|
@ -486,7 +485,7 @@ int32_t MV_PlayVOC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return voice->handle;
|
||||
|
|
|
@ -43,7 +43,7 @@ void MV_Mix16BitMono(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[usample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(SCALE_SAMPLE(MV_LeftVolume[usample0], MV_GlobalVolume) + *dest, INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,9 @@ void MV_Mix16BitStereo(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[usample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(SCALE_SAMPLE(MV_LeftVolume[usample0], MV_GlobalVolume) + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
= (int16_t)clamp(MV_RightVolume[usample0] + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
= (int16_t)clamp(SCALE_SAMPLE(MV_RightVolume[usample0], MV_GlobalVolume) + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,8 @@ void MV_Mix16BitMono16(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
int32_t const sample0 = (SCALE_SAMPLE(MV_LeftVolume[usample0.l()], MV_GlobalVolume) >> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample0.h()], MV_GlobalVolume) + 128;
|
||||
|
||||
*dest = (int16_t)clamp(sample0 + *dest, INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
|
@ -118,8 +119,10 @@ void MV_Mix16BitStereo16(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
int32_t const sample1 = (MV_RightVolume[usample0.l()] >> 8) + MV_RightVolume[usample0.h()] + 128;
|
||||
int32_t const sample0 = (SCALE_SAMPLE(MV_LeftVolume[usample0.l()], MV_GlobalVolume) >> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample0.h()], MV_GlobalVolume) + 128;
|
||||
int32_t const sample1 = (SCALE_SAMPLE(MV_RightVolume[usample0.l()], MV_GlobalVolume) >> 8) +
|
||||
SCALE_SAMPLE(MV_RightVolume[usample0.h()], MV_GlobalVolume) + 128;
|
||||
|
||||
*dest = (int16_t)clamp(sample0 + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
|
|
|
@ -43,7 +43,8 @@ void MV_Mix16BitMono8Stereo(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(((MV_LeftVolume[usample0] + MV_LeftVolume[usample1]) >> 1) + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(((SCALE_SAMPLE(MV_LeftVolume[usample0], MV_GlobalVolume) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample1], MV_GlobalVolume)) >> 1) + *dest, INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -67,9 +68,9 @@ void MV_Mix16BitStereo8Stereo(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
*dest = (int16_t)clamp(MV_LeftVolume[usample0] + *dest, INT16_MIN, INT16_MAX);
|
||||
*dest = (int16_t)clamp(SCALE_SAMPLE(MV_LeftVolume[usample0], MV_GlobalVolume) + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
= (int16_t)clamp(MV_RightVolume[usample1] + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
= (int16_t)clamp(SCALE_SAMPLE(MV_RightVolume[usample1], MV_GlobalVolume) + *(dest + (MV_RightChannelOffset >> 1)), INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
}
|
||||
|
||||
|
@ -95,8 +96,10 @@ void MV_Mix16BitMono16Stereo(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
int32_t const sample1 = (MV_LeftVolume[usample1.l()] >> 8) + MV_LeftVolume[usample1.h()] + 128;
|
||||
int32_t const sample0 = (SCALE_SAMPLE(MV_LeftVolume[usample0.l()], MV_GlobalVolume)>> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample0.h()], MV_GlobalVolume) + 128;
|
||||
int32_t const sample1 = (SCALE_SAMPLE(MV_LeftVolume[usample1.l()], MV_GlobalVolume) >> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample1.h()], MV_GlobalVolume) + 128;
|
||||
|
||||
*dest = (int16_t)clamp(((sample0 + sample1) >> 1) + *dest, INT16_MIN, INT16_MAX);
|
||||
dest += MV_SampleSize >> 1;
|
||||
|
@ -124,8 +127,10 @@ void MV_Mix16BitStereo16Stereo(struct VoiceNode *voice, uint32_t length)
|
|||
|
||||
position += rate;
|
||||
|
||||
int32_t const sample0 = (MV_LeftVolume[usample0.l()] >> 8) + MV_LeftVolume[usample0.h()] + 128;
|
||||
int32_t const sample1 = (MV_RightVolume[usample1.l()] >> 8) + MV_RightVolume[usample1.h()] + 128;
|
||||
int32_t const sample0 = (SCALE_SAMPLE(MV_LeftVolume[usample0.l()], MV_GlobalVolume)>> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample0.h()], MV_GlobalVolume) + 128;
|
||||
int32_t const sample1 = (SCALE_SAMPLE(MV_LeftVolume[usample1.l()], MV_GlobalVolume) >> 8) +
|
||||
SCALE_SAMPLE(MV_LeftVolume[usample1.h()], MV_GlobalVolume) + 128;
|
||||
|
||||
*dest = (int16_t)clamp(sample0 + *dest, INT16_MIN, INT16_MAX);
|
||||
*(dest + (MV_RightChannelOffset >> 1))
|
||||
|
|
|
@ -94,6 +94,8 @@ uint32_t MV_MixPosition;
|
|||
|
||||
int32_t MV_ErrorCode = MV_NotInstalled;
|
||||
|
||||
float MV_GlobalVolume = 1.f;
|
||||
|
||||
static int32_t lockdepth = 0;
|
||||
|
||||
static FORCE_INLINE void DisableInterrupts(void)
|
||||
|
@ -156,7 +158,6 @@ static void MV_Mix(VoiceNode *voice, int const buffer)
|
|||
// Add this voice to the mix
|
||||
do
|
||||
{
|
||||
const char *start = voice->sound;
|
||||
uint32_t const rate = voice->RateScale;
|
||||
uint32_t const position = voice->position;
|
||||
int32_t voclength;
|
||||
|
@ -176,9 +177,15 @@ static void MV_Mix(VoiceNode *voice, int const buffer)
|
|||
else
|
||||
voclength = length;
|
||||
|
||||
float const gv = MV_GlobalVolume;
|
||||
|
||||
if (voice->priority == FX_MUSIC_PRIORITY)
|
||||
MV_GlobalVolume = 1.f;
|
||||
|
||||
if (voice->mix)
|
||||
voice->mix(voice, voclength);
|
||||
|
||||
MV_GlobalVolume = gv;
|
||||
voice->position = MV_MixPosition;
|
||||
|
||||
length -= voclength;
|
||||
|
@ -647,7 +654,7 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
|
|||
}
|
||||
}
|
||||
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right)
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume)
|
||||
{
|
||||
if (MV_Channels == 1)
|
||||
left = right = vol;
|
||||
|
@ -664,6 +671,8 @@ void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t righ
|
|||
swapptr(&voice->LeftVolume, &voice->RightVolume);
|
||||
}
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceMixMode(voice);
|
||||
}
|
||||
|
||||
|
@ -757,7 +766,7 @@ int32_t MV_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
|
|||
if (voice == NULL)
|
||||
return MV_Error;
|
||||
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, MV_GetVoice(handle)->volume);
|
||||
MV_EndService();
|
||||
return MV_Ok;
|
||||
}
|
||||
|
@ -894,8 +903,9 @@ static void MV_CalcPanTable(void)
|
|||
|
||||
void MV_SetVolume(int32_t volume)
|
||||
{
|
||||
MV_TotalVolume = min(max(0, volume), MV_MAXTOTALVOLUME);
|
||||
MV_CalcVolume(MV_TotalVolume);
|
||||
MV_TotalVolume = min(max(0, volume), MV_MAXTOTALVOLUME);
|
||||
MV_GlobalVolume = (float)volume / 255.f;
|
||||
// MV_CalcVolume(MV_TotalVolume);
|
||||
}
|
||||
|
||||
int32_t MV_GetVolume(void) { return MV_TotalVolume; }
|
||||
|
@ -975,8 +985,7 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
|
|||
|
||||
// Calculate pan table
|
||||
MV_CalcPanTable();
|
||||
|
||||
MV_SetVolume(MV_MAXTOTALVOLUME);
|
||||
MV_CalcVolume(MV_MAXTOTALVOLUME);
|
||||
|
||||
// Start the playback engine
|
||||
if (MV_StartPlayback() != MV_Ok)
|
||||
|
|
|
@ -458,9 +458,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
|
|||
MV_SetVoicePitch(voice, vi->rate, pitchoffset);
|
||||
MV_SetVoiceMixMode( voice );
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceVolume( voice, vol, left, right );
|
||||
MV_SetVoiceVolume( voice, vol, left, right, volume );
|
||||
MV_PlayVoice( voice );
|
||||
|
||||
return voice->handle;
|
||||
|
|
|
@ -474,9 +474,7 @@ int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend
|
|||
voice->LoopEnd = 0;
|
||||
voice->LoopSize = (loopstart >= 0 ? 1 : 0);
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceVolume( voice, vol, left, right );
|
||||
MV_SetVoiceVolume( voice, vol, left, right, volume );
|
||||
MV_PlayVoice( voice );
|
||||
|
||||
return voice->handle;
|
||||
|
|
|
@ -187,9 +187,7 @@ int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
voice->FixedPointBufferSize = (voice->RateScale * MV_MIXBUFFERSIZE) - voice->RateScale;
|
||||
MV_SetVoiceMixMode(voice);
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoiceVolume(voice, vol, left, right);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return voice->handle;
|
||||
|
|
|
@ -190,8 +190,7 @@ void CONFIG_SetDefaults(void)
|
|||
ud.config.NoAutoLoad = 1;
|
||||
ud.config.AmbienceToggle = 1;
|
||||
ud.config.AutoAim = 1;
|
||||
ud.config.MasterVolume = 255;
|
||||
ud.config.FXVolume = 225;
|
||||
ud.config.FXVolume = 255;
|
||||
#if defined(_WIN32)
|
||||
ud.config.MixRate = 44100;
|
||||
#elif defined __ANDROID__
|
||||
|
|
|
@ -4464,7 +4464,7 @@ extern int G_StartRTS(int lumpNum, int localPlayer)
|
|||
|
||||
if (pData != NULL)
|
||||
{
|
||||
FX_Play3D(pData, RTS_SoundLength(lumpNum - 1), FX_ONESHOT, 0, 0, FX_VOLUME(1), 255, 1.f, -lumpNum);
|
||||
FX_Play3D(pData, RTS_SoundLength(lumpNum - 1), FX_ONESHOT, 0, 0, 1, 255, 1.f, -lumpNum);
|
||||
g_RTSPlaying = 7;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,6 @@ typedef struct {
|
|||
//
|
||||
// Sound variables
|
||||
//
|
||||
int32_t MasterVolume;
|
||||
int32_t FXVolume;
|
||||
int32_t MusicVolume;
|
||||
int32_t SoundToggle;
|
||||
|
|
|
@ -1164,11 +1164,8 @@ static MenuEntry_t ME_SOUND = MAKE_MENUENTRY( "Sound:", &MF_Redfont, &MEF_BigOpt
|
|||
static MenuOption_t MEO_SOUND_MUSIC = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.config.MusicToggle );
|
||||
static MenuEntry_t ME_SOUND_MUSIC = MAKE_MENUENTRY( "Music:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_MUSIC, Option );
|
||||
|
||||
static MenuRangeInt32_t MEO_SOUND_VOLUME_MASTER = MAKE_MENURANGE( &ud.config.MasterVolume, &MF_Redfont, 0, 255, 0, 33, 2 );
|
||||
static MenuEntry_t ME_SOUND_VOLUME_MASTER = MAKE_MENUENTRY( "Volume:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_VOLUME_MASTER, RangeInt32 );
|
||||
|
||||
static MenuRangeInt32_t MEO_SOUND_VOLUME_EFFECTS = MAKE_MENURANGE( &ud.config.FXVolume, &MF_Redfont, 0, 255, 0, 33, 2 );
|
||||
static MenuEntry_t ME_SOUND_VOLUME_EFFECTS = MAKE_MENUENTRY( "Effects:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_VOLUME_EFFECTS, RangeInt32 );
|
||||
static MenuRangeInt32_t MEO_SOUND_VOLUME_FX = MAKE_MENURANGE( &ud.config.FXVolume, &MF_Redfont, 0, 255, 0, 33, 2 );
|
||||
static MenuEntry_t ME_SOUND_VOLUME_FX = MAKE_MENUENTRY( "Volume:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_VOLUME_FX, RangeInt32 );
|
||||
|
||||
static MenuRangeInt32_t MEO_SOUND_VOLUME_MUSIC = MAKE_MENURANGE( &ud.config.MusicVolume, &MF_Redfont, 0, 255, 0, 33, 2 );
|
||||
static MenuEntry_t ME_SOUND_VOLUME_MUSIC = MAKE_MENUENTRY( "Music:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_VOLUME_MUSIC, RangeInt32 );
|
||||
|
@ -1201,8 +1198,7 @@ static MenuEntry_t ME_SOUND_ADVSOUND = MAKE_MENUENTRY( "Advanced", &MF_Redfont,
|
|||
static MenuEntry_t *MEL_SOUND[] = {
|
||||
&ME_SOUND,
|
||||
&ME_SOUND_MUSIC,
|
||||
&ME_SOUND_VOLUME_MASTER,
|
||||
&ME_SOUND_VOLUME_EFFECTS,
|
||||
&ME_SOUND_VOLUME_FX,
|
||||
&ME_SOUND_VOLUME_MUSIC,
|
||||
&ME_SOUND_DUKETALK,
|
||||
#ifndef EDUKE32_SIMPLE_MENU
|
||||
|
@ -2001,8 +1997,7 @@ static void Menu_Pre(MenuID_t cm)
|
|||
case MENU_SOUND:
|
||||
case MENU_SOUND_INGAME:
|
||||
case MENU_ADVSOUND:
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_MASTER, !ud.config.SoundToggle && !ud.config.MusicToggle);
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_EFFECTS, !ud.config.SoundToggle);
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_FX, !ud.config.SoundToggle);
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_MUSIC, !ud.config.MusicToggle);
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_DUKETALK, !ud.config.SoundToggle);
|
||||
MenuEntry_DisableOnCondition(&ME_SOUND_SAMPLINGRATE, !ud.config.SoundToggle && !ud.config.MusicToggle);
|
||||
|
@ -3317,13 +3312,10 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue)
|
|||
G_SetViewportShrink((newValue - vpsize) * 4);
|
||||
else if (entry == &ME_SCREENSETUP_SBARSIZE)
|
||||
G_SetStatusBarScale(newValue);
|
||||
else if (entry == &ME_SOUND_VOLUME_MASTER)
|
||||
{
|
||||
else if (entry == &ME_SOUND_VOLUME_FX)
|
||||
FX_SetVolume(newValue);
|
||||
S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume));
|
||||
}
|
||||
else if (entry == &ME_SOUND_VOLUME_MUSIC)
|
||||
S_MusicVolume(MASTER_VOLUME(newValue));
|
||||
S_MusicVolume(newValue);
|
||||
else if (entry == &ME_MOUSEADVANCED_SCALEX)
|
||||
CONTROL_SetAnalogAxisScale(0, newValue, controldevice_mouse);
|
||||
else if (entry == &ME_MOUSEADVANCED_SCALEY)
|
||||
|
|
|
@ -1731,8 +1731,7 @@ int32_t registerosdcommands(void)
|
|||
|
||||
{ "snd_ambience", "enables/disables ambient sounds", (void *)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 1 },
|
||||
{ "snd_enabled", "enables/disables sound effects", (void *)&ud.config.SoundToggle, CVAR_BOOL, 0, 1 },
|
||||
{ "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_fxvolume", "controls volume for sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 0, 255 },
|
||||
{ "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 },
|
||||
{ "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 },
|
||||
{ "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 1, 128 },
|
||||
|
|
|
@ -74,8 +74,8 @@ void S_SoundStartup(void)
|
|||
|
||||
S_PrecacheSounds();
|
||||
|
||||
FX_SetVolume(ud.config.MasterVolume);
|
||||
S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume));
|
||||
FX_SetVolume(ud.config.FXVolume);
|
||||
S_MusicVolume(ud.config.MusicVolume);
|
||||
|
||||
FX_SetReverseStereo(ud.config.ReverseStereo);
|
||||
FX_SetCallBack(S_Callback);
|
||||
|
@ -100,7 +100,7 @@ void S_MusicStartup(void)
|
|||
|
||||
if (MUSIC_Init(0, 0) == MUSIC_Ok || MUSIC_Init(1, 0) == MUSIC_Ok)
|
||||
{
|
||||
MUSIC_SetVolume(MASTER_VOLUME(ud.config.MusicVolume));
|
||||
MUSIC_SetVolume(ud.config.MusicVolume);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -248,10 +248,8 @@ static int S_PlayMusic(const char *fn)
|
|||
}
|
||||
else
|
||||
{
|
||||
int32_t const mvol = MASTER_VOLUME(ud.config.MusicVolume);
|
||||
int MyMusicVoice = FX_Play(MyMusicPtr, MusicLen, 0, 0,
|
||||
0, mvol, mvol, mvol,
|
||||
FX_MUSIC_PRIORITY, 1.f, MUSIC_ID);
|
||||
int MyMusicVoice = FX_Play(MyMusicPtr, MusicLen, 0, 0, 0, ud.config.MusicVolume, ud.config.MusicVolume, ud.config.MusicVolume,
|
||||
FX_MUSIC_PRIORITY, 1.f, MUSIC_ID);
|
||||
|
||||
if (MyMusicVoice <= FX_Ok)
|
||||
{
|
||||
|
@ -726,9 +724,9 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
|
|||
// XXX: why is 'right' 0?
|
||||
// Ambient MUSICANDSFX always start playing using the 3D routines!
|
||||
int const ambsfxp = S_IsAmbientSFX(spriteNum);
|
||||
int const voice = (repeatp && !ambsfxp) ? FX_Play(snd.ptr, snd.siz, 0, -1, pitch, FX_VOLUME(sndist >> 6), FX_VOLUME(sndist >> 6), 0, snd.pr,
|
||||
int const voice = (repeatp && !ambsfxp) ? FX_Play(snd.ptr, snd.siz, 0, -1, pitch, sndist >> 6, sndist >> 6, 0, snd.pr,
|
||||
snd.volume, (sndNum * MAXSOUNDINSTANCES) + sndSlot)
|
||||
: FX_Play3D(snd.ptr, snd.siz, repeatp ? FX_LOOP : FX_ONESHOT, pitch, sndang >> 4, FX_VOLUME(sndist >> 6),
|
||||
: FX_Play3D(snd.ptr, snd.siz, repeatp ? FX_LOOP : FX_ONESHOT, pitch, sndang >> 4, sndist >> 6,
|
||||
snd.pr, snd.volume, (sndNum * MAXSOUNDINSTANCES) + sndSlot);
|
||||
|
||||
if (voice <= FX_Ok)
|
||||
|
@ -779,9 +777,9 @@ int S_PlaySound(int num)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int const voice = (snd.m & SF_LOOP) ? FX_Play(snd.ptr, snd.siz, 0, -1, pitch, FX_VOLUME(LOUDESTVOLUME), FX_VOLUME(LOUDESTVOLUME),
|
||||
FX_VOLUME(LOUDESTVOLUME), snd.siz, snd.volume, (num * MAXSOUNDINSTANCES) + sndnum)
|
||||
: FX_Play3D(snd.ptr, snd.siz, FX_ONESHOT, pitch, 0, FX_VOLUME(255 - LOUDESTVOLUME), snd.pr, snd.volume,
|
||||
int const voice = (snd.m & SF_LOOP) ? FX_Play(snd.ptr, snd.siz, 0, -1, pitch, LOUDESTVOLUME, LOUDESTVOLUME,
|
||||
LOUDESTVOLUME, snd.siz, snd.volume, (num * MAXSOUNDINSTANCES) + sndnum)
|
||||
: FX_Play3D(snd.ptr, snd.siz, FX_ONESHOT, pitch, 0, 255 - LOUDESTVOLUME, snd.pr, snd.volume,
|
||||
(num * MAXSOUNDINSTANCES) + sndnum);
|
||||
|
||||
if (voice <= FX_Ok)
|
||||
|
@ -909,7 +907,7 @@ void S_Update(void)
|
|||
g_numEnvSoundsPlaying++;
|
||||
|
||||
// AMBIENT_SOUND
|
||||
FX_Pan3D(voice.id, sndang >> 4, FX_VOLUME(sndist >> 6));
|
||||
FX_Pan3D(voice.id, sndang >> 4, sndist >> 6);
|
||||
voice.dist = sndist >> 6;
|
||||
voice.clock++;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,6 @@ extern "C" {
|
|||
#define LOUDESTVOLUME 111
|
||||
#define MUSIC_ID -65536
|
||||
|
||||
#define FX_VOLUME(x) (ud.config.FXVolume > 0 ? scale(x, 255, ud.config.FXVolume) : 0)
|
||||
#define MASTER_VOLUME(x) scale(ud.config.MasterVolume, x, 255)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t owner;
|
||||
|
|
Loading…
Reference in a new issue