Skip to content

Commit 65d87c6

Browse files
committed
CHG: sound loudness slider now follows a x^4 curve, approximates an exponential loudness control for finer adjustments
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11909 8aca7d54-2c30-db11-9de9-000461428c89
1 parent 540bbe5 commit 65d87c6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

simutrans/history.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
FIX: Overcrowded stops can cause unhappy return passengers in unconnected networks
6969
FIX: Factory editor could not select water factories from climate selection
7070
FIX: Transformers get removed by factory field expansion
71+
CHG: sound loudness slider now follows a x^4 curve, approximates an exponential loudness control for finer adjustments
7172

7273

7374
Release of 124.3.1 (r11671 on 5-Apr-2025):

src/simutrans/gui/sound_frame.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ bool sound_frame_t::action_triggered( gui_action_creator_t *comp, value_t p)
209209
sound_set_global_volume(p.i);
210210
}
211211
else if (comp == &music_volume_scrollbar) {
212-
sound_set_midi_volume(p.i);
212+
uint32 volume = p.i;
213+
volume = (volume * volume * volume * volume) / 16581375ul; // (255 ^ 3) approximates a logarithmic sound, see https://www.dr-lex.be/info-stuff/volumecontrols.html
214+
sound_set_midi_volume(volume);
213215
}
214216
else if (comp == &sound_range) {
215217
env_t::sound_distance_scaling = p.i;
@@ -222,7 +224,9 @@ bool sound_frame_t::action_triggered( gui_action_creator_t *comp, value_t p)
222224
else {
223225
for( int i = 0; i < MAX_SOUND_TYPES; i++ ) {
224226
if( comp == specific_volume_scrollbar[ i ] ) {
225-
sound_set_specific_volume( p.i, (sound_type_t)i );
227+
uint32 volume = p.i;
228+
volume = (volume * volume * volume * volume) / 16581375ul; // (255 ^ 3) approximates a logarithmic sound
229+
sound_set_specific_volume( volume, (sound_type_t)i );
226230
}
227231
}
228232
}

0 commit comments

Comments
 (0)