Skip to content

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Source/RunActivity/Viewer3D/Sound.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,19 +1420,28 @@ private void SetFreqAndVolume()
14201420
volume *= Interpolate(x, MSTSStream.VolumeCurves[i]);
14211421
}
14221422

1423-
var wag = (MSTSWagon)SoundSource.Viewer.Camera.AttachedCar;
1424-
var soundHeardInternallyCorrection = Math.Min(wag.SoundHeardInternallyCorrection[0] + wag.SoundHeardInternallyCorrection[1], 1);
1425-
if (SoundSource.IsExternal && SoundSource.Viewer.Camera.Style != Camera.Styles.External && !SoundSource.IsUnattenuated)
1423+
if (SoundSource.Viewer.Camera.Style != Camera.Styles.External)
14261424
{
1427-
if (wag == null || wag.ExternalSoundPassThruPercent == -1)
1428-
volume *= Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f + (1 - Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1429-
else volume *= wag.ExternalSoundPassThruPercent * 0.01f + (1 - wag.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1425+
var wag = (MSTSWagon)SoundSource.Viewer.Camera.AttachedCar;
1426+
var soundHeardInternallyCorrection = Math.Min(wag.SoundHeardInternallyCorrection[0] + wag.SoundHeardInternallyCorrection[1], 1);
1427+
if (SoundSource.IsExternal && !SoundSource.IsUnattenuated)
1428+
{
1429+
if (wag == null || wag.ExternalSoundPassThruPercent == -1)
1430+
volume *= Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f + (1 - Program.Viewer.Settings.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1431+
else volume *= wag.ExternalSoundPassThruPercent * 0.01f + (1 - wag.ExternalSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1432+
}
1433+
1434+
if (SoundSource.IsInternalTrackSound)
1435+
{
1436+
if (wag?.TrackSoundPassThruPercent != -1)
1437+
volume *= wag.TrackSoundPassThruPercent * 0.01f + (1 - wag.TrackSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1438+
}
14301439
}
14311440

14321441
if (SoundSource.IsInternalTrackSound && SoundSource.Viewer.Camera.Style != Camera.Styles.External)
14331442
{
1434-
if (wag?.TrackSoundPassThruPercent != -1)
1435-
volume *= wag.TrackSoundPassThruPercent * 0.01f + (1 - wag.TrackSoundPassThruPercent * 0.01f) * soundHeardInternallyCorrection;
1443+
if (((MSTSWagon)SoundSource.Viewer.Camera.AttachedCar)?.TrackSoundPassThruPercent != -1)
1444+
volume *= ((MSTSWagon)SoundSource.Viewer.Camera.AttachedCar).TrackSoundPassThruPercent * 0.01f;
14361445
}
14371446

14381447
ALSoundSource.Volume = volume;

0 commit comments

Comments
 (0)