Vixen
02b45cc4
csharp
public sealed class ClipSampleProvider

Plays an AudioClip that is already in memory.

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

Remarks

The conversion from the clip's stored format to float happens here, one block at a time, rather than once at load. Converting at load would triple the memory a 16-bit clip costs for the whole time it is resident, to save a multiply per sample on the frames that are actually playing — and the frames actually playing are a few hundred out of the millions resident.

The scale is 1 / 32768 and not 1 / 32767. That maps −32 768 to exactly −1 and 32 767 to just under +1, which is the asymmetry two's complement actually has. Dividing by 32 767 makes the most negative sample clip.

Fields and properties (5)

  • public AudioClip Clip

    The clip being played.

  • public AudioFormat Format

    The rate and channel count of what Read produces.

  • public long FrameCount

    How many frames there are in total, or -1 if that is not knowable.

  • public long Position

    Where the next Read will start, in frames.

  • public bool IsLooping

    Whether it will keep producing after it has run out.

Methods (3)

  • public ClipSampleProvider(AudioClip clip, bool loop = false)

    A provider over a clip.

  • public int Read(Span<float> destination, int frameCount)

    Produces the next frames.

  • public void Seek(long frame)

    Starts again from a frame.

Used by (2)

  • AudioEngineVixen.Audio
  • ConvolutionReverbEffectVixen.Audio