Member Junction
    Preparing search index...

    Function BuildRecordingFromSegments

    • Assembles recovered recording shards into one WAV, in index order, filling every absent index with silence. Silence (rather than skipping the gap) keeps all later audio at its true time offset, so it stays aligned with transcript cues, which are offsets from the session's RecordingStartedAt.

      The gap length is the median length of the present shards excluding the highest present index (that one is normally a partial window); with a single shard, that shard's length. It is rounded down to an even byte count (whole 16-bit samples), minimum 2.

      The byte ceiling does not bound the index range on its own: under the default ceiling a single shard at index ~10^9 still fits, and the missing-index list grows with the highest index. Callers handling untrusted shards must cap the shard count and highest index themselves (recovery does, via MAX_RECOVERY_SEGMENTS) and pass a smaller maxDataBytes.

      Parameters

      • segments: RecordingSegmentBytes[]

        Recovered shards; any order, unique non-negative integer indexes starting from 0.

      • sampleRate: number

        Sample rate of the PCM data, in Hz.

      • maxDataBytes: number = RECORDING_MAX_DATA_BYTES

        Ceiling on the PCM data size (shards plus gap fill), checked before anything is allocated. Defaults to the WAV format's own limit; callers handling untrusted shards pass less.

      Returns AssembledRecording

      Error on no segments, an invalid sample rate or index, a duplicate index, an empty or odd-length shard, or a result too large for a WAV.