linear loudness scale on the music and sound volume settings

This commit is contained in:
ipatix 2016-12-17 14:18:08 +01:00 committed by Ted John
parent 56c338bd3a
commit ae6ed2978d
2 changed files with 16 additions and 2 deletions

View File

@ -578,6 +578,16 @@ void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length)
void Mixer::MixChannel(Channel& channel, uint8* data, int length)
{
// Did the volume level get changed? Recalculate level in this case.
if (setting_sound_vol != gConfigSound.sound_volume) {
setting_sound_vol = gConfigSound.sound_volume;
adjust_sound_vol = powf(setting_sound_vol / 100.f, 10.f / 6.f);
}
if (setting_music_vol != gConfigSound.ride_music_volume) {
setting_music_vol = gConfigSound.ride_music_volume;
adjust_music_vol = powf(setting_music_vol / 100.f, 10.f / 6.f);
}
// Do not mix channel if channel is a sound and sound is disabled
if (channel.group == MIXER_GROUP_SOUND && !gConfigSound.sound_enabled) {
return;
@ -675,7 +685,7 @@ void Mixer::MixChannel(Channel& channel, uint8* data, int length)
volumeadjust *= (gConfigSound.master_volume / 100.0f);
switch (channel.group) {
case MIXER_GROUP_SOUND:
volumeadjust *= (gConfigSound.sound_volume / 100.0f);
volumeadjust *= adjust_sound_vol;
// Cap sound volume on title screen so music is more audible
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) {
@ -683,7 +693,7 @@ void Mixer::MixChannel(Channel& channel, uint8* data, int length)
}
break;
case MIXER_GROUP_RIDE_MUSIC:
volumeadjust *= (gConfigSound.ride_music_volume / 100.0f);
volumeadjust *= adjust_music_vol;
break;
}
int startvolume = (int)(channel.oldvolume * volumeadjust);

View File

@ -184,6 +184,10 @@ private:
std::list<Channel*> channels;
Source_Null source_null;
float volume = 1.0f;
float adjust_sound_vol = 0.0f;
float adjust_music_vol = 0.0f;
uint8 setting_sound_vol = 0xFF;
uint8 setting_music_vol = 0xFF;
};
extern "C"