Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Csantucci committed Jul 22, 2023
1 parent 1bdb7df commit 410a585
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Source/RunActivity/Viewer3D/Sound.cs
Expand Up @@ -1420,19 +1420,28 @@ private void SetFreqAndVolume()
volume *= Interpolate(x, MSTSStream.VolumeCurves[i]);
}

var wag = (MSTSWagon)SoundSource.Viewer.Camera.AttachedCar;
var soundHeardInternallyCorrection = Math.Min(wag.SoundHeardInternallyCorrection[0] + wag.SoundHeardInternallyCorrection[1], 1);
if (SoundSource.IsExternal && SoundSource.Viewer.Camera.Style != Camera.Styles.External && !SoundSource.IsUnattenuated)
if (SoundSource.Viewer.Camera.Style != Camera.Styles.External)
{
if (wag == null || wag.ExternalSoundPassThruPercent == -1)
volume *= Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f + (1 - Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
else volume *= wag.ExternalSoundPassThruPercent * 0.01f + (1 - wag.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
var wag = (MSTSWagon)SoundSource.Viewer.Camera.AttachedCar;
var soundHeardInternallyCorrection = Math.Min(wag.SoundHeardInternallyCorrection[0] + wag.SoundHeardInternallyCorrection[1], 1);
if (SoundSource.IsExternal && !SoundSource.IsUnattenuated)
{
if (wag == null || wag.ExternalSoundPassThruPercent == -1)
volume *= Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f + (1 - Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
else volume *= wag.ExternalSoundPassThruPercent * 0.01f + (1 - wag.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
}

if (SoundSource.IsInternalTrackSound)
{
if (wag?.TrackSoundPassThruPercent != -1)
volume *= wag.TrackSoundPassThruPercent * 0.01f + (1 - wag.TrackSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
}
}

if (SoundSource.IsInternalTrackSound && SoundSource.Viewer.Camera.Style != Camera.Styles.External)
{
if (wag?.TrackSoundPassThruPercent != -1)
volume *= wag.TrackSoundPassThruPercent * 0.01f + (1 - wag.TrackSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
if (((MSTSWagon)SoundSource.Viewer.Camera.AttachedCar)?.TrackSoundPassThruPercent != -1)
volume *= ((MSTSWagon)SoundSource.Viewer.Camera.AttachedCar).TrackSoundPassThruPercent * 0.01f;
}

ALSoundSource.Volume = volume;
Expand Down

0 comments on commit 410a585

Please sign in to comment.