View Issue Details

IDProjectCategoryView StatusLast Update
0006491The Dark ModSound Systempublic15.06.2024 13:48
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionTDM 2.12 
Target VersionTDM 2.13Fixed in VersionTDM 2.13 
Summary0006491: Estimate current volume of played sound for subtitles
DescriptionVolume of played sound is a sum of volume modifier (gain) and volume of sound sample data.
For the purpose of volume display in subtitles, we only use gain right now.
We should add some way to track sound sample amplitude, preferably max over some duration (a second maybe).

When it is done, add a volume lower bound for when to display subtitle.
Right now subtitles are often visible when they are inaudible quiet.
Steps To ReproduceThe guards dialog in New Job is a good example where subtitles volume value is wrong.
The heard volume is the same for both guards, but the volume indicator is very different.
TagsNo tags attached.




15.06.2024 13:48

administrator   ~0016741

  r10800 Estimate current sound sample volume for each channel, use it to set subtitles alpha.

The average sample magnitude was easy to track: I simply use streamed sample data at the moment when it is pushed into OpenAL.
It goes there in blocks of 4096 samples (44100 samples per second).
I compute maximum magnitude in a block, and maintain "exponential moving average" over these values.

There are three tdm_subtitles_volumeXyz cvars which affect how the raw volume is used.
The idea is that:
  alpha = 0 at volume <= Min
  alpha = 1 at volume >= Max
  alpha grows logarithmically in-between

Also now I hide subtitles for sounds with volume < Min.
Typically volume fluctuates about 11 times per second, so if it is near Min, then subtitles can start blinking.
To reduce this issue a bit, I hide a currently displayed subtitle only if its volume falls below MinDisappear.

The default values are:
  0.001 = tdm_subtitles_volumeMinDisappear
  0.003 = tdm_subtitles_volumeMin
  0.1 = tdm_subtitles_volumeMax

Feels good to me =)

Issue History

Date Modified Username Field Change
18.02.2024 10:03 stgatilov New Issue
15.06.2024 13:48 stgatilov Note Added: 0016741
15.06.2024 13:48 stgatilov Assigned To => stgatilov
15.06.2024 13:48 stgatilov Status new => resolved
15.06.2024 13:48 stgatilov Resolution open => fixed
15.06.2024 13:48 stgatilov Fixed in Version => TDM 2.13