Vixen
02b45cc4
csharp
public record class AudioClip

Decoded audio: interleaved samples, and what they mean.

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

Remarks

Interleaved and not planar, because that is what every backend's buffer submission takes — OpenAL, WASAPI, AudioUnit, WebAudio's copyToChannel being the exception that deinterleaves on the way in anyway. Planar would be better for a mixer that processes channels independently, and worse for the far more common job of handing bytes to a driver.

The samples are bytes, not short[] or float[]. The format is a value on the clip rather than a fact about the type, so one array is the only representation that does not need the clip to be generic — and a generic [DataContract] is a build error here for good reasons. AsInt16 and AsFloat32 reinterpret without copying. Little-endian, like everything else the serializer writes, so a clip built on one machine loads on another.

What this is not. There is no streaming here — a clip is entirely in memory. A track too big to hold is played through Vixen.Audio.Streaming.StreamingSampleProvider instead, which is a handle onto a decoder rather than a buffer. Doc 08 wants Ogg or Opus for that; PcmStreamDecoder is the implementation that needs no codec, and a codec plugs in behind the same interface.

Fields and properties (7)

  • public int SampleRate

    Frames per second — 44 100, 48 000.

  • public int Channels

    How many channels are interleaved. One for a sound that will be positioned in the world.

  • public AudioSampleFormat Format

    How one sample is stored.

  • public byte[] Samples

    The interleaved samples.

  • public int BytesPerSample

    How many bytes one sample of one channel takes.

  • public int FrameCount

    How many frames — one sample for every channel — the clip holds.

  • public TimeSpan Duration

    How long it plays for.

Methods (2)

  • public ReadOnlySpan<short> AsInt16()

    The samples as signed 16-bit values.

  • public ReadOnlySpan<float> AsFloat32()

    The samples as floats in −1..1.

Used by (37)

  • GameSoundsThirdPersonShooter
  • AudioClipRefVixen.Audio
  • AudioClipTestsVixen.Audio.Tests
  • AudioEngineVixen.Audio
  • AudioEventVixen.Audio
  • AudioEventAssetTestsVixen.Audio.Tests
  • AudioEventBuilderVixen.Audio
  • AudioEventVariantVixen.Audio
  • AudioEventVariantAssetVixen.Audio
  • AudioSystemVixen.Audio
  • AudioSystemTestsVixen.Audio.Tests
  • AudioTestDataVixen.Audio.Tests
  • ClipSampleProviderVixen.Audio
  • ConvolutionReverbEffectVixen.Audio
  • ConvolutionTestsVixen.Audio.Tests
  • LayeredEventTestsVixen.Audio.Tests
  • MusicPlayerVixen.Audio
  • MusicPlayerTestsVixen.Audio.Tests
  • MusicSegmentVixen.Audio
  • MusicSegmentAssetVixen.Audio
  • OpenALBackendTestsVixen.Audio.Backend.OpenAL.Tests
  • ResamplerTestsVixen.Audio.Tests
  • SerializerRegistrationVixen.Audio
  • SpatializerTestsVixen.Audio.Tests
  • StreamingTestsVixen.Audio.Tests
  • TypeRegistrationVixen.Audio
  • VirtualVoiceTestsVixen.Audio.Tests
  • Vixen_Audio_Assets_AudioEventVariantAssetSerializerVixen.Audio
  • Vixen_Audio_Assets_MusicSegmentAssetSerializerVixen.Audio
  • Vixen_Audio_AudioClipSerializerVixen.Audio
  • Vixen_Audio_Ecs_AudioClipRefSerializerVixen.Audio
  • VoiceParameterTestsVixen.Audio.Tests
  • AudioImporterVixen.Editor.Assets
  • AudioImporterTestsVixen.Editor.Assets.Tests
  • IAudioDecoderVixen.Editor.Assets
  • WaveDecoderVixen.Editor.Assets
  • WaveDecoderTestsVixen.Editor.Assets.Tests