Cut 5d-1: Haven audio curation, WetMix PcmSynth, WalkerFootstepTracker & ArenaAudioSystem
This commit is contained in:
parent
9081d2bb5c
commit
7f811c3011
41 changed files with 3067 additions and 10 deletions
1081
client/ArenaAudioSystem.cs
Normal file
1081
client/ArenaAudioSystem.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -24,6 +24,7 @@ public partial class Main : Node3D
|
|||
private TerrainRenderer _terrain = null!;
|
||||
private SionMapRenderer _sionMap = null!;
|
||||
private ArenaRenderer _arena = null!;
|
||||
private ArenaAudioSystem _audio = null!;
|
||||
private Camera3D _camera = null!;
|
||||
private Hud _hud = null!;
|
||||
private DirectionalLight3D _sun = null!;
|
||||
|
|
@ -32,6 +33,9 @@ public partial class Main : Node3D
|
|||
private IClientArenaSession? _session;
|
||||
private MatchState? _boundViewState;
|
||||
private bool _wasNetConnected;
|
||||
private readonly WalkerFootstepTracker _footsteps = new();
|
||||
private readonly List<ISimEvent> _frameEvents = new(128);
|
||||
private readonly List<FootstepPulse> _frameFootsteps = new(32);
|
||||
private ArenaMapKind _mapKind = ArenaMapKind.Sion;
|
||||
private string _callsign = "Pilot";
|
||||
private string _lastEndpoint = $"127.0.0.1:{DefaultNetPort}";
|
||||
|
|
@ -74,6 +78,8 @@ public partial class Main : Node3D
|
|||
public TerrainRenderer Terrain => _terrain;
|
||||
public SionMapRenderer SionMap => _sionMap;
|
||||
public ArenaRenderer Arena => _arena;
|
||||
public ArenaAudioSystem Audio => _audio;
|
||||
public WalkerFootstepTracker Footsteps => _footsteps;
|
||||
public Hud Hud => _hud;
|
||||
public ArenaMapKind MapKind => _mapKind;
|
||||
public ArenaMapKind? InitialMapKindOverride { get; set; }
|
||||
|
|
@ -94,6 +100,9 @@ public partial class Main : Node3D
|
|||
_arena = new ArenaRenderer { Name = "Arena" };
|
||||
AddChild(_arena);
|
||||
|
||||
_audio = new ArenaAudioSystem { Name = "ArenaAudio" };
|
||||
AddChild(_audio);
|
||||
|
||||
_camera = new Camera3D
|
||||
{
|
||||
Name = "ShoulderCamera",
|
||||
|
|
@ -392,6 +401,10 @@ public partial class Main : Node3D
|
|||
_cameraPitch = _mapKind == ArenaMapKind.Sion ? Mathf.DegToRad(5f) : Mathf.DegToRad(12f);
|
||||
_cameraZoom = 1.0f;
|
||||
_lastCamChassisId = null;
|
||||
_footsteps.Clear();
|
||||
_frameEvents.Clear();
|
||||
_frameFootsteps.Clear();
|
||||
_audio.ClearAll();
|
||||
}
|
||||
|
||||
_camera.Far = _mapKind == ArenaMapKind.Sion ? 4200f : 1800f;
|
||||
|
|
@ -711,6 +724,7 @@ public partial class Main : Node3D
|
|||
|
||||
long tc0 = Stopwatch.GetTimestamp();
|
||||
UpdateCamera((float)delta, alpha);
|
||||
StepAudioAndFootsteps((float)delta, alpha);
|
||||
if (_mapKind == ArenaMapKind.Sion)
|
||||
{
|
||||
_sionMap.UpdateLod(_camera.GlobalPosition);
|
||||
|
|
@ -763,6 +777,7 @@ public partial class Main : Node3D
|
|||
}
|
||||
_arena.Sync(_session, _elapsedSeconds, (float)delta, alpha);
|
||||
UpdateCamera((float)delta, alpha);
|
||||
StepAudioAndFootsteps((float)delta, alpha);
|
||||
if (_mapKind == ArenaMapKind.Sion)
|
||||
{
|
||||
_sionMap.UpdateLod(_camera.GlobalPosition);
|
||||
|
|
@ -775,6 +790,43 @@ public partial class Main : Node3D
|
|||
}
|
||||
}
|
||||
|
||||
private void StepAudioAndFootsteps(float dt, float alpha)
|
||||
{
|
||||
if (_session is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_frameEvents.Clear();
|
||||
_session.DrainSimEvents(_frameEvents);
|
||||
|
||||
_frameFootsteps.Clear();
|
||||
_footsteps.StepSession(_session, dt, alpha, _frameFootsteps, ResolveLiveWalkerFootWorld);
|
||||
|
||||
_audio.UpdateFrame(_session, _frameEvents, _frameFootsteps, _camera.GlobalPosition, dt, alpha);
|
||||
}
|
||||
|
||||
private System.Numerics.Vector3? ResolveLiveWalkerFootWorld(bool isContender, int id, int legIndex)
|
||||
{
|
||||
VehicleVisualInstance? vis = isContender
|
||||
? _arena.GetContenderVisual(id)
|
||||
: _arena.GetSpectatorVisual(id);
|
||||
if (vis is null || vis.IsStaticLod || vis.RigState?.WalkerRig is not { } rig)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if ((uint)legIndex >= (uint)rig.Legs.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Node3D footNode = rig.Legs[legIndex].Foot.Node;
|
||||
if (!GodotObject.IsInstanceValid(footNode) || !footNode.IsInsideTree())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Vector3 p = footNode.GlobalPosition;
|
||||
return new System.Numerics.Vector3(p.X, p.Y, p.Z);
|
||||
}
|
||||
|
||||
private void PrintPerfSummaryAndQuit()
|
||||
{
|
||||
static double Avg(List<double> v)
|
||||
|
|
|
|||
119
client/ProceduralAudioBank.cs
Normal file
119
client/ProceduralAudioBank.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Godot;
|
||||
using RustToDust.Core;
|
||||
using RustToDust.Core.Audio;
|
||||
|
||||
namespace RustToDust.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Owns all immutable <see cref="AudioStreamWav"/> assets built once at client startup:
|
||||
/// 25 curated Haven Kendrick WAVs from <c>assets/audio/haven/</c> plus all deterministic
|
||||
/// <see cref="PcmSynth"/> procedural clips (with separable <see cref="WetMixMode"/>).
|
||||
/// Zero <c>.import</c> sidecar dependency.
|
||||
/// </summary>
|
||||
public sealed class ProceduralAudioBank
|
||||
{
|
||||
public static readonly string[] ExpectedHavenClips =
|
||||
{
|
||||
"mg_shot_01", "mg_shot_02", "mg_tail",
|
||||
"ac_light_01", "ac_light_02", "ac_med_01", "ac_rotary",
|
||||
"flak_blast_01", "flak_blast_02", "cannon_heavy_01", "cannon_heavy_02",
|
||||
"pd_bark_01", "pd_bark_02", "pd_laser",
|
||||
"rocket_salvo_01", "rocket_salvo_02",
|
||||
"plasma_ppc_01", "plasma_ppc_02", "lance_beam_01", "laser_heavy_01", "gauss_rail_01",
|
||||
"mech_reload_bolt", "mech_quick_bolt", "mech_eject", "mech_turret_servo"
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, AudioStreamWav> _streams = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public ProceduralAudioBank(bool wetMixMode = true, string? havenDirOverride = null)
|
||||
{
|
||||
WetMixMode = wetMixMode;
|
||||
LoadHavenClips(havenDirOverride ?? LocateHavenAudioDirectory());
|
||||
BuildProceduralClips(wetMixMode);
|
||||
}
|
||||
|
||||
public bool WetMixMode { get; private set; }
|
||||
public int HavenClipCount { get; private set; }
|
||||
public int ProceduralClipCount { get; private set; }
|
||||
public int TotalClipCount => _streams.Count;
|
||||
|
||||
public bool TryGetStream(string key, out AudioStreamWav stream) =>
|
||||
_streams.TryGetValue(key, out stream!);
|
||||
|
||||
public AudioStreamWav GetStream(string key) =>
|
||||
_streams.TryGetValue(key, out var stream)
|
||||
? stream
|
||||
: throw new KeyNotFoundException($"Missing audio clip '{key}' in ProceduralAudioBank.");
|
||||
|
||||
public void RebuildProcedural(bool wetMixMode)
|
||||
{
|
||||
WetMixMode = wetMixMode;
|
||||
BuildProceduralClips(wetMixMode);
|
||||
}
|
||||
|
||||
public static string LocateHavenAudioDirectory()
|
||||
{
|
||||
string vehiclesDir = VehicleCatalogLoader.LocateVehiclesDirectory();
|
||||
string assetsDir = Directory.GetParent(vehiclesDir)?.FullName
|
||||
?? throw new DirectoryNotFoundException("Could not locate assets directory.");
|
||||
string havenDir = Path.Combine(assetsDir, "audio", "haven");
|
||||
if (!Directory.Exists(havenDir))
|
||||
{
|
||||
throw new DirectoryNotFoundException($"Curated Haven audio directory not found: {havenDir}");
|
||||
}
|
||||
return havenDir;
|
||||
}
|
||||
|
||||
private void LoadHavenClips(string havenDir)
|
||||
{
|
||||
int loaded = 0;
|
||||
for (int i = 0; i < ExpectedHavenClips.Length; i++)
|
||||
{
|
||||
string key = ExpectedHavenClips[i];
|
||||
string path = Path.Combine(havenDir, key + ".wav");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
throw new FileNotFoundException($"Missing curated Haven WAV '{path}'.", path);
|
||||
}
|
||||
|
||||
WavPcmInfo wav = WavFileReader.ReadMonoOrStereo16(path);
|
||||
var stream = new AudioStreamWav
|
||||
{
|
||||
Format = AudioStreamWav.FormatEnum.Format16Bits,
|
||||
MixRate = wav.SampleRate,
|
||||
Stereo = wav.Channels == 2,
|
||||
LoopMode = AudioStreamWav.LoopModeEnum.Disabled,
|
||||
Data = wav.PcmBytes
|
||||
};
|
||||
_streams[key] = stream;
|
||||
loaded++;
|
||||
}
|
||||
HavenClipCount = loaded;
|
||||
}
|
||||
|
||||
private void BuildProceduralClips(bool wetMixMode)
|
||||
{
|
||||
Dictionary<string, PcmClipData> clips = PcmSynth.SynthesizeAll(wetMixMode);
|
||||
int count = 0;
|
||||
foreach (var kv in clips)
|
||||
{
|
||||
PcmClipData clip = kv.Value;
|
||||
var stream = new AudioStreamWav
|
||||
{
|
||||
Format = AudioStreamWav.FormatEnum.Format16Bits,
|
||||
MixRate = clip.SampleRate,
|
||||
Stereo = false,
|
||||
LoopMode = clip.IsLoop ? AudioStreamWav.LoopModeEnum.Forward : AudioStreamWav.LoopModeEnum.Disabled,
|
||||
LoopBegin = 0,
|
||||
LoopEnd = clip.IsLoop ? clip.Samples.Length : 0,
|
||||
Data = clip.Pcm16Bytes
|
||||
};
|
||||
_streams[clip.Key] = stream;
|
||||
count++;
|
||||
}
|
||||
ProceduralClipCount = count;
|
||||
}
|
||||
}
|
||||
196
client/WalkerFootstepTracker.cs
Normal file
196
client/WalkerFootstepTracker.cs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using RustToDust.Core;
|
||||
using RustToDust.Ymir;
|
||||
|
||||
namespace RustToDust.Client;
|
||||
|
||||
public readonly record struct FootstepPulse(
|
||||
bool IsContender,
|
||||
int EntityId,
|
||||
int LegIndex,
|
||||
string ChassisId,
|
||||
float MassKg,
|
||||
float LoadG,
|
||||
Vector3 WorldPos);
|
||||
|
||||
/// <summary>
|
||||
/// Tracks per-walker leg GRF hysteresis (<c>LoadG</c> arming < 0.10, touchdown >= 0.24,
|
||||
/// 0.18 s cooldown) from interpolated <see cref="WalkerVisualSnapshot"/>s across both Solo and
|
||||
/// Multiplayer (<see cref="IClientArenaSession"/>). Zero Godot dependency so xUnit and headless
|
||||
/// Godot tests run the exact same edge detector.
|
||||
/// </summary>
|
||||
public sealed class WalkerFootstepTracker
|
||||
{
|
||||
public const float ArmLoadGThreshold = 0.10f;
|
||||
public const float TriggerLoadGThreshold = 0.24f;
|
||||
public const float LegCooldownSec = 0.18f;
|
||||
|
||||
private struct LegHysteresis
|
||||
{
|
||||
public bool Armed;
|
||||
public float Cooldown;
|
||||
}
|
||||
|
||||
private sealed class WalkerTrackState
|
||||
{
|
||||
public string ChassisId = string.Empty;
|
||||
public int LegCount;
|
||||
public readonly LegHysteresis[] Legs = new LegHysteresis[4];
|
||||
}
|
||||
|
||||
private readonly Dictionary<(bool IsContender, int Id), WalkerTrackState> _walkers = new();
|
||||
|
||||
public int TrackedWalkerCount => _walkers.Count;
|
||||
|
||||
public void Clear() => _walkers.Clear();
|
||||
|
||||
public void StepSession(
|
||||
IClientArenaSession session,
|
||||
float dt,
|
||||
float alpha,
|
||||
List<FootstepPulse> outPulses,
|
||||
Func<bool, int, int, Vector3?>? resolveLiveFootWorld = null)
|
||||
{
|
||||
var state = session.ViewState;
|
||||
var contenders = state.Contenders;
|
||||
for (int i = 0; i < contenders.Count; i++)
|
||||
{
|
||||
var c = contenders[i];
|
||||
if (!c.Alive || !c.Grid.Spec.IsWalker || !session.IsContenderVisible(c.Id))
|
||||
{
|
||||
_walkers.Remove((true, c.Id));
|
||||
continue;
|
||||
}
|
||||
if (!session.TrySampleInterpolatedWalkerPose(true, c.Id, alpha, out var snap))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
StepActor(
|
||||
isContender: true,
|
||||
entityId: c.Id,
|
||||
chassisId: c.Grid.Spec.Id,
|
||||
massKg: c.Grid.Spec.MassKg,
|
||||
in snap,
|
||||
state.Terrain,
|
||||
dt,
|
||||
outPulses,
|
||||
resolveLiveFootWorld);
|
||||
}
|
||||
|
||||
var specs = state.Spectators.Spectators;
|
||||
for (int i = 0; i < specs.Count; i++)
|
||||
{
|
||||
var s = specs[i];
|
||||
if (!s.Alive || !s.Grid.Spec.IsWalker || !session.IsSpectatorVisible(s.Id))
|
||||
{
|
||||
_walkers.Remove((false, s.Id));
|
||||
continue;
|
||||
}
|
||||
if (!session.TrySampleInterpolatedWalkerPose(false, s.Id, alpha, out var snap))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
StepActor(
|
||||
isContender: false,
|
||||
entityId: s.Id,
|
||||
chassisId: s.Grid.Spec.Id,
|
||||
massKg: s.Grid.Spec.MassKg,
|
||||
in snap,
|
||||
state.Terrain,
|
||||
dt,
|
||||
outPulses,
|
||||
resolveLiveFootWorld);
|
||||
}
|
||||
}
|
||||
|
||||
public void StepActor(
|
||||
bool isContender,
|
||||
int entityId,
|
||||
string chassisId,
|
||||
float massKg,
|
||||
in WalkerVisualSnapshot snap,
|
||||
TerrainField terrain,
|
||||
float dt,
|
||||
List<FootstepPulse> outPulses,
|
||||
Func<bool, int, int, Vector3?>? resolveLiveFootWorld = null)
|
||||
{
|
||||
int legCount = Math.Clamp(snap.LegCount, 0, 4);
|
||||
if (legCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var key = (isContender, entityId);
|
||||
if (!_walkers.TryGetValue(key, out var track) ||
|
||||
!string.Equals(track.ChassisId, chassisId, StringComparison.OrdinalIgnoreCase) ||
|
||||
track.LegCount != legCount)
|
||||
{
|
||||
track = new WalkerTrackState
|
||||
{
|
||||
ChassisId = chassisId,
|
||||
LegCount = legCount
|
||||
};
|
||||
// First sighting initializes Armed = false for zero spawn / swap pop
|
||||
_walkers[key] = track;
|
||||
return;
|
||||
}
|
||||
|
||||
float stepDt = MathF.Max(0f, dt);
|
||||
WalkerGeometrySpec? geom = null;
|
||||
float geomScale = snap.GeomScale > 0.01f ? snap.GeomScale : 1f;
|
||||
Quaternion comRot = snap.ComRot.LengthSquared() > 1e-6f
|
||||
? Quaternion.Normalize(snap.ComRot)
|
||||
: Quaternion.Identity;
|
||||
|
||||
for (int i = 0; i < legCount; i++)
|
||||
{
|
||||
ref LegHysteresis leg = ref track.Legs[i];
|
||||
if (leg.Cooldown > 0f)
|
||||
{
|
||||
leg.Cooldown = MathF.Max(0f, leg.Cooldown - stepDt);
|
||||
}
|
||||
|
||||
float loadG = snap.LoadG[i];
|
||||
if (loadG < ArmLoadGThreshold)
|
||||
{
|
||||
leg.Armed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (leg.Armed && loadG >= TriggerLoadGThreshold && leg.Cooldown <= 0f)
|
||||
{
|
||||
leg.Armed = false;
|
||||
leg.Cooldown = LegCooldownSec;
|
||||
|
||||
Vector3? liveFoot = resolveLiveFootWorld?.Invoke(isContender, entityId, i);
|
||||
Vector3 footWorld;
|
||||
if (liveFoot.HasValue)
|
||||
{
|
||||
float fy = terrain.SampleHeight(liveFoot.Value.X, liveFoot.Value.Z);
|
||||
footWorld = new Vector3(liveFoot.Value.X, fy, liveFoot.Value.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
geom ??= WalkerGeometrySpec.GetForChassis(chassisId);
|
||||
Vector2 restXZ = geom.Legs[i].RestFootXZ * geomScale;
|
||||
Vector3 offset = Vector3.Transform(new Vector3(restXZ.X, 0f, restXZ.Y), comRot);
|
||||
float fx = snap.ComPos.X + offset.X;
|
||||
float fz = snap.ComPos.Z + offset.Z;
|
||||
float fy = terrain.SampleHeight(fx, fz);
|
||||
footWorld = new Vector3(fx, fy, fz);
|
||||
}
|
||||
|
||||
outPulses.Add(new FootstepPulse(
|
||||
isContender,
|
||||
entityId,
|
||||
i,
|
||||
chassisId,
|
||||
massKg,
|
||||
loadG,
|
||||
footWorld));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1283,6 +1283,116 @@ public partial class Smoke : Node
|
|||
Check(remoteIface.LocalContender.Alive, "Expected loopback RemoteArenaSession LocalContender alive");
|
||||
}
|
||||
|
||||
// 14. Cut 5d-1: Headless AudioBank, voice-cap/priority/dedupe, and mass-scaled GRF footstep pitch falsification
|
||||
{
|
||||
var audio = _main.Audio;
|
||||
audio.EnsureInitialized();
|
||||
Check(audio.Bank.HavenClipCount == 25, $"Expected 25 curated Haven clips in ProceduralAudioBank, got {audio.Bank.HavenClipCount}");
|
||||
Check(audio.Bank.ProceduralClipCount == 18, $"Expected 18 procedural clips in ProceduralAudioBank, got {audio.Bank.ProceduralClipCount}");
|
||||
|
||||
audio.ClearAll();
|
||||
audio.ResetStatsForTest();
|
||||
var localC = _main.Session.LocalContender;
|
||||
Vector3 listener = new(localC.X, localC.Y, localC.Z);
|
||||
|
||||
var burstEvents = new List<ISimEvent>();
|
||||
// Local player shot first (priority 10)
|
||||
burstEvents.Add(new ShotFiredEvent
|
||||
{
|
||||
TracerId = 90001,
|
||||
IsSpectatorShooter = false,
|
||||
ShooterId = _main.Session.LocalContenderId,
|
||||
StartX = listener.X,
|
||||
StartY = listener.Y + 1f,
|
||||
StartZ = listener.Z,
|
||||
EndX = listener.X + 40f,
|
||||
EndY = listener.Y + 1f,
|
||||
EndZ = listener.Z,
|
||||
WeaponClass = (byte)WeaponVisualClass.KineticLight,
|
||||
WeaponId = "mg_762"
|
||||
});
|
||||
|
||||
// 5-pellet flak salvo from contender 1 -> must dedupe to 1 audio voice
|
||||
for (int p = 0; p < 5; p++)
|
||||
{
|
||||
burstEvents.Add(new ShotFiredEvent
|
||||
{
|
||||
TracerId = 90010 + p,
|
||||
IsSpectatorShooter = false,
|
||||
ShooterId = 1,
|
||||
StartX = listener.X + 18f,
|
||||
StartY = listener.Y + 1f,
|
||||
StartZ = listener.Z,
|
||||
EndX = listener.X,
|
||||
EndY = listener.Y + 1f,
|
||||
EndZ = listener.Z,
|
||||
WeaponClass = (byte)WeaponVisualClass.Explosive,
|
||||
WeaponId = "flak"
|
||||
});
|
||||
}
|
||||
|
||||
// 30 simultaneous distant AI shots (>150m, <240m) trying to saturate all 19 one-shot voices
|
||||
for (int a = 2; a < 32; a++)
|
||||
{
|
||||
burstEvents.Add(new ShotFiredEvent
|
||||
{
|
||||
TracerId = 90100 + a,
|
||||
IsSpectatorShooter = false,
|
||||
ShooterId = a,
|
||||
StartX = listener.X + 175f,
|
||||
StartY = listener.Y + 1f,
|
||||
StartZ = listener.Z + (a % 5),
|
||||
EndX = listener.X,
|
||||
EndY = listener.Y + 1f,
|
||||
EndZ = listener.Z,
|
||||
WeaponClass = (byte)WeaponVisualClass.Autocannon,
|
||||
WeaponId = "autocannon"
|
||||
});
|
||||
}
|
||||
|
||||
// 1 event beyond MaxAudioDistance (260m) -> must be culled (0 voices)
|
||||
burstEvents.Add(new ShotFiredEvent
|
||||
{
|
||||
TracerId = 90999,
|
||||
IsSpectatorShooter = false,
|
||||
ShooterId = 99,
|
||||
StartX = listener.X + 320f,
|
||||
StartY = listener.Y + 1f,
|
||||
StartZ = listener.Z,
|
||||
EndX = listener.X,
|
||||
EndY = listener.Y + 1f,
|
||||
EndZ = listener.Z,
|
||||
WeaponClass = (byte)WeaponVisualClass.Explosive,
|
||||
WeaponId = "recoilless"
|
||||
});
|
||||
|
||||
audio.ConsumeSimEvents(_main.Session, burstEvents, listener);
|
||||
Check(audio.Active3DVoiceCount <= ArenaAudioSystem.Total3DVoiceCount,
|
||||
$"Active 3D voices exceeded 24 cap: {audio.Active3DVoiceCount}");
|
||||
Check(audio.ActiveOneShotVoiceCount == ArenaAudioSystem.OneShotVoiceCount,
|
||||
$"Expected 19 saturated one-shot voices, got {audio.ActiveOneShotVoiceCount}");
|
||||
Check(audio.DedupedCount == 4,
|
||||
$"Expected 5-pellet flak salvo to dedupe 4 pellets, got DedupedCount={audio.DedupedCount}");
|
||||
Check(audio.RejectedDistanceCount == 1,
|
||||
$"Expected >260m event to be distance-culled, got RejectedDistanceCount={audio.RejectedDistanceCount}");
|
||||
Check(audio.HasActiveVoiceForSource(isLocalSource: true, sourceEntityId: _main.Session.LocalContenderId),
|
||||
"Expected local player priority-10 voice never to be stolen by distant AI shots");
|
||||
|
||||
// Footstep mass-scaled pitch verification: Bastion (4600 kg) pitch < Kestrel (1650 kg) pitch
|
||||
audio.ClearAll();
|
||||
var kestrelPulse = new FootstepPulse(true, 0, 0, "kestrel", Catalog.Kestrel.MassKg, 1.0f, new System.Numerics.Vector3(listener.X, listener.Y, listener.Z));
|
||||
audio.ConsumeFootsteps(new[] { kestrelPulse }, _main.Session.LocalContenderId, listener);
|
||||
float? kestrelPitch = audio.GetLastPitchForClipPrefix("footstep_");
|
||||
|
||||
var bastionPulse = new FootstepPulse(true, 1, 0, "bastion", Catalog.Bastion.MassKg, 1.0f, new System.Numerics.Vector3(listener.X + 10f, listener.Y, listener.Z));
|
||||
audio.ConsumeFootsteps(new[] { bastionPulse }, _main.Session.LocalContenderId, listener);
|
||||
float? bastionPitch = audio.GetLastPitchForClipPrefix("footstep_heavy_");
|
||||
|
||||
Check(kestrelPitch.HasValue && bastionPitch.HasValue && bastionPitch.Value < kestrelPitch.Value,
|
||||
$"Expected Bastion pitch ({bastionPitch}) < Kestrel pitch ({kestrelPitch})");
|
||||
GD.Print($"SMOKE INFO: Audio verified (haven={audio.Bank.HavenClipCount}, proc={audio.Bank.ProceduralClipCount}, dummy={audio.IsDummyAudio}, kestrelPitch={kestrelPitch:F3}, bastionPitch={bastionPitch:F3})");
|
||||
}
|
||||
|
||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue