-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAudioProcessing.cs
73 lines (58 loc) · 2.21 KB
/
AudioProcessing.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using GTA;
using KlangRageAudioLibrary.Utility;
namespace KlangRageAudioLibrary
{
public partial class AudioPlayer
{
private void ProcessFadeIn()
{
Last.Volume =
MathUtils.Lerp(Last.Volume, _originalVolume, Game.LastFrameTime * FadeInMultiplier);
if (!(Last.Volume >= _originalVolume - 0.05f))
return;
Last.Volume = _originalVolume;
IsDoingFadeIn = false;
}
private void ProcessFadeOut()
{
Last.Volume =
MathUtils.Lerp(Last.Volume, 0f, Game.LastFrameTime * FadeOutMultiplier);
if (!(Last.Volume <= 0.05f))
return;
IsDoingFadeOut = false;
Last.Stop();
}
private void ProcessInteriorSound()
{
if (SourceEntity is Vehicle is false)
return;
if (IsInteriorSound is false)
return;
// If player is in the source vehicle we use original sound volume
if (Main.PlayerVehicle == SourceEntity)
{
SoundInstances.ForEach(x => x.Volume = _originalVolume);
return;
}
// Define volume based on is car doors open / closed
SoundInstances.ForEach(x => x.Volume =
VehicleUtils.IsAnyPassengerDoorOpen((Vehicle)SourceEntity) ? _originalVolume : _originalVolume / 4);
}
private void ProcessExteriorSound()
{
if (SourceEntity is Vehicle is false)
return;
if (IsExteriorSound is false)
return;
// If player is in the source vehicle and use 3rd person mode we use original sound volume
if (Main.PlayerVehicle == SourceEntity == false || CameraUtils.IsPlayerUseFirstPerson() == false)
{
SoundInstances.ForEach(x => x.Volume = _originalVolume);
return;
}
// Define volume based on is car doors open / closed
SoundInstances.ForEach(x => x.Volume =
VehicleUtils.IsAnyPassengerDoorOpen((Vehicle)SourceEntity) ? _originalVolume : _originalVolume / 2);
}
}
}