Vixen
02b45cc4
csharp
public struct AudioSource

A sound attached to an entity.

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

As a scene component

Size
48 bytes — 273 rows in a 16 KB chunk, alone on the archetype

Remarks

Unmanaged, so a scene full of emitters is a sweep over chunks. The clip itself is a reference and lives in AudioClipRef beside it — one indirection, taken once when a sound starts rather than once per entity per frame.

A zeroed AudioSource is silent and stopped, which is why Default exists: default gives a gain of zero and a pitch of zero, and a pitch of zero is a sound that never advances. Anything creating one by hand starts from Default, exactly as LocalTransform.Identity does.

Fields and properties (12)

  • public AudioPlayback Playback

    What it should be doing.

  • public int Bus

    Which bus it routes into. Zero is the master.

  • public float Gain

    Its linear gain.

  • public float Pitch

    Its playback rate multiplier.

  • public float Pan

    Where it sits between the speakers, when it is not spatialised.

  • public bool Loop

    Whether it wraps round instead of ending.

  • public int Priority

    How hard it is to displace when the voice pool is full. Higher survives.

  • public VoiceHandle Voice

    The voice it is playing on. Written by the system; read by anything that wants the detail.

  • public float VoiceGainScale

    What the sound that started decided its own gain was. Owned by the system.

  • public float VoicePitchScale

    What the sound that started decided its own pitch ratio was. Owned by the system.

  • public static AudioSource Default

    Full volume, unaltered pitch, centred, on the master bus, stopped.

  • public static AudioSource Playing

    The same, already playing.

Used by (13)

  • AudioEventSystemTestsVixen.Audio.Tests
  • AudioSystemVixen.Audio
  • AudioSystemTestsVixen.Audio.Tests
  • ComponentRegistrationVixen.Audio
  • NetworkAudioApplySystemVixen.Net.Audio
  • NetworkAudioCaptureSystemVixen.Net.Audio
  • NetworkAudioTestsVixen.Net.Audio.Tests
  • TypeRegistrationVixen.Audio
  • Vixen_Audio_Ecs_AudioSourceSerializerVixen.Audio
  • AddComponentMenuTestsVixen.Editor.App.Tests
  • ComponentTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • MaterialIconsVixen.Editor.App