Skip to content

streaming: accept optional zstd/float16-compressed source frames#225

Draft
gioelecerati wants to merge 1 commit into
mainfrom
feat/compact-source-frame
Draft

streaming: accept optional zstd/float16-compressed source frames#225
gioelecerati wants to merge 1 commit into
mainfrom
feat/compact-source-frame

Conversation

@gioelecerati

Copy link
Copy Markdown
Collaborator

What

Make the streaming binary source decoder (_decode_audio_msg) accept an
optional, backward-compatible compact frame alongside the existing
raw-float32 frame.

Compact frame layout:

<I sentinel=0xFFFFFFFF><B flags><II channels,samples> + payload
flags bit0 = zstd-compressed, bit1 = float16 samples

The legacy frame (<II channels,samples> + float32) is unchanged — the
channel count is always 1/2, so it can never collide with the sentinel.

Why

The uploaded source is only a conditioning reference (it's encoded straight
to a latent), so its sample precision is irrelevant. float16 halves it; zstd
then crushes repetitive/looped material. Net: much smaller source uploads,
no audible change, faster connect.

Compatibility

  • Fully backward-compatible: existing clients keep sending float32 → legacy path.
  • Accepted encodings are advertised in ready.src_encodings so clients can
    feature-gate (and fall back to float32 against older servers).
  • Shared decoder, so init / swap_source / timbre / structure all benefit.

Draft — opening for review of the wire format.

The binary source decoder (_decode_audio_msg) only accepted raw float32
PCM. Add an optional, backward-compatible compact framing: a 0xFFFFFFFF
sentinel (never a valid channel count) + a flags byte selecting zstd
compression and/or float16 samples. Legacy float32 frames are unchanged.

The source is only a conditioning reference (it gets encoded to a latent),
so float16 + zstd shrink uploads substantially with no audible cost -
especially for repetitive/looped material. The accepted encodings are
advertised in the ready payload (src_encodings) so clients can gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant