Page MenuHomeFeedback Tracker

Inactive FadeIn prohibits volume changes on newly created EffectSound.
Assigned, UrgentPublic

Description

It's impossible to set a volume on an EffectSound immediately after creation resulting in a !LOUD! BURst of audio until volume can be set sometime later.

This code from the engine (effectsound.c) looks incorrect as it sets volume to maximum (1.0) if there is no fade in on the next frame.

    override void Event_OnFrameUpdate(float time_delta)
    {
...
            // FadeIn
            if ( m_SoundWaveStarting )
            {
                if ( m_SoundFadeInDuration > 0 )
                {
                    SetSoundVolume( GetSoundVolume() + (time_delta / m_SoundFadeInDuration) );
                    
                    if ( GetSoundVolume() >= m_SoundWaveVolumeMax )
                    {
                        Event_OnSoundFadeInStopped();
                        SetSoundVolume( m_SoundWaveVolumeMax );
                        m_SoundWaveStarting = false;
                    }
                }
                else
                {
                    SetSoundVolume( m_SoundWaveVolumeMax );
                    m_SoundWaveStarting = false;
                }
            }

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 11 x64
Category
General
Steps To Reproduce
auto sound = SEffectManager.PlaySoundOnObject(<SOMELONGSOUND>, this);
sound.SetSoundVolume(0);
Additional Information

Working around by setting both maxvolume and volume. The documentation is rather lacking. Since it's clearly not "purely used for fade in", it always applies.

/**
	\brief Set the sound max volume
		\warning Seems to purely be used for fade in effect, rather than really setting the max volume...
		\warning Adjusts the current volume to this value as well
		\param volume \p float The maximum volume for the sound
	*/
	void SetSoundMaxVolume(float volume)
	{
		m_SoundWaveVolumeMax = volume;
		if ( m_SoundWaveObject )
			m_SoundWaveObject.SetVolumeRelative( m_SoundWaveVolume );
	}

Event Timeline

antihax created this task.Jul 14 2023, 6:28 AM
Geez changed the task status from New to Assigned.Jul 14 2023, 10:33 AM