Member Junction
    Preparing search index...

    Accumulates realtime PCM audio frames from both the model (outbound) and the user (inbound) and mixes them into a single mono PCM16 WAV on demand.

    Lifecycle: construct → StartAppendOutbound/AppendInbound (many) → StopEncodeWav. Reset returns the instance to a pristine state so it can be reused.

    Index

    Constructors

    Accessors

    Methods

    • Append a model-output audio frame (ArrayBuffer of little-endian PCM16). No-op if not recording or empty. The bytes are copied — the caller's ArrayBuffer is not retained.

      Parameters

      • chunk: ArrayBuffer

      Returns void

    • Mix everything captured into a mono PCM16 WAV.

      Returns { Buffer: Buffer; DurationMs: number; SampleRate: number }

      The encoded buffer, duration, and sample rate; or null if HasAudio is false.

    • Compute capture-time waveform peaks from the accumulated PCM: a normalized 0..1 max-abs amplitude per bucket (one bucket per rendered waveform bar). Mirrors the client-direct peak math so server-bridged recordings render the same kind of waveform; the result is persisted as a peaks.json sidecar so a viewer renders the waveform without re-decoding the audio.

      Parameters

      • buckets: number = DEFAULT_PEAK_BUCKETS

        Desired bucket count (waveform resolution). Default 600; clamped to >= 1 and never exceeds the sample count (a short recording yields at most one peak per sample).

      Returns number[]

      A bounded array of normalized 0..1 peaks; [] when there is no audio (or silence).