Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ public void PlaySound(CharacterSound.SoundType soundType, float soundIntervalFac
}
var selectedSound = matchingSounds.GetRandomUnsynced();
if (selectedSound?.Sound == null) { return; }
soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: CurrentHull, ignoreMuffling: selectedSound.IgnoreMuffling);
soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: CurrentHull, ignoreMuffling: selectedSound.IgnoreMuffling, freqMult: selectedSound.GetRandomFrequencyMultiplier());
soundTimer = Params.SoundInterval;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Barotrauma.Sounds;
using Microsoft.Xna.Framework;
using System.Collections.Immutable;

namespace Barotrauma
Expand All @@ -16,6 +17,8 @@ public enum SoundType
public SoundType Type => Params.State;
public ImmutableHashSet<Identifier> TagSet => Params.TagSet;
public float Volume => roundSound == null ? 0.0f : roundSound.Volume;

public Vector2 FrequencyMultiplierRange => roundSound == null ? new Vector2(1.0f) : roundSound.FrequencyMultiplierRange;
public float Range => roundSound == null ? 0.0f : roundSound.Range;
public Sound Sound => roundSound?.Sound;

Expand All @@ -26,5 +29,10 @@ public CharacterSound(CharacterParams.SoundParams soundParams)
Params = soundParams;
roundSound = RoundSound.Load(soundParams.Element);
}

public float GetRandomFrequencyMultiplier()
{
return Rand.Range(FrequencyMultiplierRange.X, FrequencyMultiplierRange.Y);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public float FrequencyMultiplier
{
if (value is < MinFrequencyMultiplier or > MaxFrequencyMultiplier)
{
DebugConsole.ThrowError($"Frequency multiplier out of range: {value}" + Environment.StackTrace.CleanupStackTrace());
DebugConsole.ThrowError($"Frequency multiplier out of range: {value} . Minimum acceptable frequency value is {MinFrequencyMultiplier} , maximum acceptable frequency value is {MaxFrequencyMultiplier} ." + Environment.StackTrace.CleanupStackTrace());
}
frequencyMultiplier = Math.Clamp(value, MinFrequencyMultiplier, MaxFrequencyMultiplier);

Expand Down