(df9b1966f) Added an option to disable directional voice chat. Closes #1414

This commit is contained in:
Joonas Rikkonen
2019-04-10 13:27:30 +03:00
parent 74da38bd10
commit 593d99ec38
11 changed files with 78 additions and 74 deletions
@@ -438,6 +438,17 @@ namespace Barotrauma
DebugConsole.NewMessage(name + " " + name.Length.ToString(), Color.Lime);
}
GUITickBox directionalVoiceChat = new GUITickBox(new RectTransform(new Point(32, 32), audioSliders.RectTransform), TextManager.Get("DirectionalVoiceChat"));
directionalVoiceChat.Selected = UseDirectionalVoiceChat;
directionalVoiceChat.ToolTip = TextManager.Get("DirectionalVoiceChatToolTip");
directionalVoiceChat.OnSelected = (tickBox) =>
{
UseDirectionalVoiceChat = tickBox.Selected;
UnsavedSettings = true;
return true;
};
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0];
#if (!OSX)
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
@@ -39,25 +39,33 @@ namespace Barotrauma.Networking
public void UpdateSoundPosition()
{
if (VoipSound != null)
if (VoipSound == null) { return; }
if (!VoipSound.IsPlaying)
{
if (!VoipSound.IsPlaying)
{
DebugConsole.Log("Destroying voipsound");
VoipSound.Dispose();
VoipSound = null;
return;
}
DebugConsole.Log("Destroying voipsound");
VoipSound.Dispose();
VoipSound = null;
return;
}
if (character != null)
if (character != null)
{
if (GameMain.Config.UseDirectionalVoiceChat)
{
VoipSound.SetPosition(new Vector3(character.WorldPosition.X, character.WorldPosition.Y, 0.0f));
}
else
{
VoipSound.SetPosition(null);
float dist = Vector3.Distance(new Vector3(character.WorldPosition, 0.0f), GameMain.SoundManager.ListenerPosition);
VoipSound.Gain = 1.0f - MathUtils.InverseLerp(VoipSound.Near, VoipSound.Far, dist);
}
}
else
{
VoipSound.SetPosition(null);
}
}
partial void InitProjSpecific()
@@ -32,6 +32,9 @@ namespace Barotrauma.Sounds
public bool UseRadioFilter;
public bool UseMuffleFilter;
public float Near { get; private set; }
public float Far { get; private set; }
private static BiQuad[] muffleFilters = new BiQuad[]
{
new LowpassFilter(VoipConfig.FREQUENCY, 800)
@@ -41,6 +44,16 @@ namespace Barotrauma.Sounds
new BandpassFilter(VoipConfig.FREQUENCY, 2000)
};
public float Gain
{
get { return soundChannel == null ? 0.0f : soundChannel.Gain; }
set
{
if (soundChannel == null) { return; }
soundChannel.Gain = value;
}
}
public VoipSound(SoundManager owner, VoipQueue q) : base(owner, "voip", true, true)
{
VoipConfig.SetupEncoding();
@@ -64,8 +77,8 @@ namespace Barotrauma.Sounds
public void SetRange(float near, float far)
{
soundChannel.Near = near;
soundChannel.Far = far;
soundChannel.Near = Near = near;
soundChannel.Far = Far = far;
}
public void ApplyFilters(short[] buffer, int readSamples)