Sendspin in Zig, both sides: a player client for Music Assistant, and a server streaming to players in sync

The server streams: one source to every player, each in its format

Group.start, write, clear and end are the program's: interleaved f32 in the source's format, sent to every player in a format of its own from those it offered -- the source's rate and channels if it takes them, else its first, resampled with zig-resample and its channels mixed. Players that chose the same format share one encoding: PCM at 16, 24 or 32 bits, FLAC a frame a chunk with the streaminfo as its codec header, Opus a 20 ms packet a chunk stamped back by the encoder's lookahead. Every chunk is 20 ms, stamped on the server's clock from a timeline set by the first write as far ahead as the slowest player asks; an encoding begun later -- a player joining, or asking with stream/request-format for another format -- is stamped from where the source had got to. write waits while it is further ahead than the players can hold, and a player whose queue is full misses a chunk rather than holding up the group. Tested with four of the library's own clients over sockets and a second of a two-tone stereo stream: PCM and 24-bit FLAC arrive sample for sample, Opus as fifty packets with the tone's energy, and PCM at 44.1 kHz exactly 44 100 frames long and within 60 dB of the tone -- all from the same first moment. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012zMkSofB1qCR4M4bBFQ2ro


Author jcollie.dev
Co-author Claude Opus 5.5 (1M context) Date Commit Parent 3deaef4b