public sealed class AudioEventA sound as a designer describes it, rather than a file as a programmer plays it.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is the layer that separates an audio engine from audio middleware. Gameplay says footsteps.Play(feet). Which of the five takes, at what pitch, how loud, on which bus, how far it carries, how many may sound at once and which one gives way when they do — all of that is the event's, and every one of those decisions is a thing a sound designer wants to change and a programmer should not have to.
It plays through the ordinary front door. Every path here ends in AudioEngine.Play with a PlaybackSettings it computed; there is no second play path into the mixer and nothing here the mixer knows about. That is deliberate — an event is an authoring idea, and the mixer stays a thing that renders voices.
Nothing is allocated by a play. The variant list, the weights, the shuffle bag and the instance table are all sized once, at construction; a play is some arithmetic, an index and a call. docs/plan/00 forbids garbage in the frame loop, and a footstep is the frame loop.
Game thread only. An event holds its selection state and its live instances without a lock, and the audio thread never sees one. Two threads playing the same event is a bug in the caller, and the shape of an engine that wants that is one event per thread.
Fields and properties (14)
public string NameWhat it is called.
public int BusWhich bus its plays route into.
public VariantSelector VariantsWhich variant plays next, and the state behind that.
public int VariantCountHow many sounds it can choose between.
public IReadOnlyList<AudioEventLayer> LayersThe other events it plays alongside itself.
public int MaxInstancesHow many copies may sound at once. Zero is no limit.
public EventStealMode StealWhat gives way when MaxInstances is reached.
public bool IsSpatialWhether its plays are things in the world.
public SpatialSettings SpatialHow its plays attenuate. The position is the caller's.
public AudioParameterSheet? ParametersThe named values its plays read, or null.
public float LastGainThe gain the last play landed on, before the caller's own trim.
public float LastPitchThe pitch ratio the last play landed on, before the caller's own trim.
public int PlayCountHow many sounds it has started since it was built.
public int InstanceCountHow many of its plays are still sounding.
Methods (9)
public AudioEvent(AudioEngine engine, AudioEventDescription description)Builds an event an engine can play.
public VoiceHandle Play()Plays it, in the room.
public VoiceHandle Play(Vector3 position)Plays it at a place in the world.
public VoiceHandle Play(in AudioEventPlayback attributes)Plays it.
public VoiceHandle Play(IAudioSampleProvider source, in AudioEventPlayback attributes)Plays something the caller produces, as this event.
public bool SetParameter(VoiceHandle handle, string name, float value)Points one of a play's parameters at a value.
public void StopAll()Stops every copy of it that is still sounding, and everything it layered.
public void FadeOutAll(TimeSpan duration, AudioFadeCurve curve = Decibel)Fades every copy of it out and stops each when it gets there.
public SpatialSettings Place(Vector3 position, Vector3 velocity, Vector3 coneDirection)The event's own spatial settings, with a caller's position filled in.
Used by (18)
- AudioEngineVixen.Audio
- AudioEventAssetTestsVixen.Audio.Tests
- AudioEventBuilderVixen.Audio
- AudioEventLayerVixen.Audio
- AudioEventRefVixen.Audio
- AudioEventSystemTestsVixen.Audio.Tests
- AudioEventTestsVixen.Audio.Tests
- AudioScattererVixen.Audio
- AudioSystemVixen.Audio
- DeferredSpawnsVixen.Audio
- IAudioEventLibraryVixen.Audio
- LayeredEventTestsVixen.Audio.Tests
- LibraryVixen.Audio.Tests
- PendingVixen.Audio
- ScattererTestsVixen.Audio.Tests
- TypeRegistrationVixen.Audio
- Vixen_Audio_Ecs_AudioEventRefSerializerVixen.Audio
- VoiceParameterTestsVixen.Audio.Tests