Vixen
02b45cc4
csharp
public sealed class AudioSystem

Makes the mixer agree with the world, once a frame.

No guide page documents this yet — the page shows what the code says about itself.

As a system

Phase
PostRender

Remarks

Declarative, not imperative. Game code writes source.Playback = AudioPlayback.Playing and this reconciles: it starts what should be playing, stops what should not, pushes the gain and the position of everything that is, and writes Stopped back when a sound runs out. So a sound survives a save and a reload — it is a component value, not a handle somebody has to have kept — and "is the alarm still going" is a component read.

In PostRender, deliberately. WorldTransform is resolved in PreRender, so this is the first phase in which a source's position is this frame's rather than last frame's — and audio has nothing to say to the renderer, so doing it after submission overlaps it with the GPU instead of competing with culling.

It does its work inline and returns the dependency it was given. The whole pass is a walk over the handful of entities that make noise, and the expensive part of audio — the mixing — is on the device's thread and not in the frame at all.

Fields and properties (3)

  • public int ListenerCount

    How many entities carried AudioListenerComponent in the last pass.

  • public int ZoneCount

    How many reverb zone entities were live in the last pass.

  • public SystemAccess Access

Methods (3)

  • public AudioSystem(AudioEngine engine)

    Makes the mixer agree with the world, once a frame.

  • public override JobHandle Update(in SystemContext context, JobHandle dependency)

    Runs the system.

  • public void Synchronize(World world, float deltaSeconds)

    Reconciles every source and the listener with the mixer.

Used by (4)

  • AudioEventSystemTestsVixen.Audio.Tests
  • AudioSystemTestsVixen.Audio.Tests
  • MultipleListenerTestsVixen.Audio.Tests
  • ReverbZoneSystemTestsVixen.Audio.Tests