f8b0295...0671290
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
int bufferSize = (int)reader.TotalSamples*reader.Channels;
|
||||
int bufferSize = (int)reader.TotalSamples * reader.Channels;
|
||||
|
||||
float[] floatBuffer = new float[bufferSize];
|
||||
short[] shortBuffer = new short[bufferSize];
|
||||
@@ -82,7 +82,7 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (!muffleFilters.TryGetValue(sampleRate, out BiQuad filter))
|
||||
{
|
||||
filter = new LowpassFilter(sampleRate, 400);
|
||||
filter = new LowpassFilter(sampleRate, 800);
|
||||
muffleFilters.Add(sampleRate, filter);
|
||||
}
|
||||
filter.Process(buffer);
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Barotrauma.Sounds
|
||||
get { return gain; }
|
||||
set
|
||||
{
|
||||
gain = Math.Max(Math.Min(value,1.0f),0.0f);
|
||||
gain = Math.Max(Math.Min(value, 1.0f), 0.0f);
|
||||
|
||||
if (ALSourceIndex < 0) return;
|
||||
|
||||
@@ -432,7 +432,13 @@ namespace Barotrauma.Sounds
|
||||
this.Category = category;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool FadingOutAndDisposing;
|
||||
public void FadeOutAndDispose()
|
||||
{
|
||||
FadingOutAndDisposing = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (mutex)
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Barotrauma.Sounds
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
Default = 0,
|
||||
Voice = 1
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private IntPtr alcDevice;
|
||||
@@ -109,12 +109,6 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
get { return loadedSounds.Select(s => s.Filename).Distinct().Count(); }
|
||||
}
|
||||
public int UniqueLoadedSoundCount
|
||||
{
|
||||
get { return loadedSounds.Select(s => s.Filename).Distinct().Count(); }
|
||||
}
|
||||
|
||||
private Dictionary<string, Pair<float, bool>> categoryModifiers;
|
||||
|
||||
private Dictionary<string, Pair<float, bool>> categoryModifiers;
|
||||
|
||||
@@ -322,7 +316,6 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
public SoundChannel GetChannelFromSound(Sound sound)
|
||||
{
|
||||
@@ -420,15 +413,6 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
else
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
else
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < playingChannels.Length; i++)
|
||||
{
|
||||
@@ -477,7 +461,8 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
for (int j = 0; j < playingChannels[i].Length; j++)
|
||||
{
|
||||
if (playingChannels[i][j] != null && playingChannels[i][j].IsStream)
|
||||
if (playingChannels[i][j] == null) { continue; }
|
||||
if (playingChannels[i][j].IsStream)
|
||||
{
|
||||
if (playingChannels[i][j].IsPlaying)
|
||||
{
|
||||
@@ -489,10 +474,18 @@ namespace Barotrauma.Sounds
|
||||
playingChannels[i][j].Dispose();
|
||||
}
|
||||
}
|
||||
else if (playingChannels[i][j].FadingOutAndDisposing)
|
||||
{
|
||||
playingChannels[i][j].Gain -= 0.1f;
|
||||
if (playingChannels[i][j].Gain <= 0.0f)
|
||||
{
|
||||
playingChannels[i][j].Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.Sleep(50); //TODO: use a separate thread for network audio?
|
||||
Thread.Sleep(10); //TODO: use a separate thread for network audio?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,19 +215,19 @@ namespace Barotrauma
|
||||
for (int i = 0; i < waterAmbienceChannels.Length; i++)
|
||||
{
|
||||
if (waterAmbienceChannels[i] == null) continue;
|
||||
waterAmbienceChannels[i].Dispose();
|
||||
waterAmbienceChannels[i].FadeOutAndDispose();
|
||||
waterAmbienceChannels[i] = null;
|
||||
}
|
||||
for (int i = 0; i < FlowSounds.Count; i++)
|
||||
{
|
||||
if (flowSoundChannels[i] == null) continue;
|
||||
flowSoundChannels[i].Dispose();
|
||||
flowSoundChannels[i].FadeOutAndDispose();
|
||||
flowSoundChannels[i] = null;
|
||||
}
|
||||
for (int i = 0; i < fireSoundChannels.Length; i++)
|
||||
{
|
||||
if (fireSoundChannels[i] == null) continue;
|
||||
fireSoundChannels[i].Dispose();
|
||||
fireSoundChannels[i].FadeOutAndDispose();
|
||||
fireSoundChannels[i] = null;
|
||||
}
|
||||
fireVolumeLeft[0] = 0.0f; fireVolumeLeft[1] = 0.0f;
|
||||
@@ -414,7 +414,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (fireSoundChannels[i] != null)
|
||||
{
|
||||
fireSoundChannels[i].Dispose();
|
||||
fireSoundChannels[i].FadeOutAndDispose();
|
||||
fireSoundChannels[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
private static BiQuad[] muffleFilters = new BiQuad[]
|
||||
{
|
||||
new LowpassFilter(VoipConfig.FREQUENCY, 400)
|
||||
new LowpassFilter(VoipConfig.FREQUENCY, 800)
|
||||
};
|
||||
private static BiQuad[] radioFilters = new BiQuad[]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user