Sound::SetVolume
function · sound · primitive
- Address
0x7a5da0· 25 bytes, up to0x7a5db8- Meaning
- Sets a sound's volume from a level 0 to 255
- Confidence
- verified, proof one
- Name from
- the community database (idb)
- Finding
- sound/engine#volume-of-a-sound
- Test
sound::volume_ramp_scale
Finding: Volume of a sound in sound: the engine
Sound::SetVolume2(v) stores v at +0x74 and, with a channel, calls FSOUND_SetVolume(ch, ftol(c · v · g · 255.0)) with g the distance gain +0x78 and c the MusicVolume factor for flag
0x2, else AmbienceVolume for 0x8, else none for 0x10, else SoundVolume. The product is in the x87
register and __ftol truncates. Sound::SetVolume(level) passes level · (1/255).
Sound::UpdateVolume reapplies +0x74, or level 0 for a sound on the fade list. 0x7a5d70 reads
a level back as the low byte of the float v · 255 + 512.5: it rounds, wraps once v · 255 ≥ 255.5
(v ≥ 1.00196), and holds only while v · 255 + 512.5 < 1024.
The derivation is in the doc.
Callers 3
- Sound::ProcessFadeList sound
- Sound::UpdateVolume sound
- Sound::RemoveFromFadeList sound
Callees 1
- Sound::SetVolume2 sound
Calls and jumps by a bare address, from tables/calls.tsv.