The pieces / weirdnet-streaming

weirdnet-streamingnew

Streaming: live and recorded audio streams over weirdnet-net, clocks and remote routing, the follow-transport protocol, and loop-positioned streams for record-along.

v0.1.0 GitHub crates.io docs.rs weirdnet-streaming = "0.1.0"

What it is

The one crate for SongNotes streaming, and the successor of weirdnet-audio-stream: it takes that crate over whole and adds what the SongNotes apps had built on top of it. A Publisher sends the frames of one stream to any number of listeners; send never blocks, because each listener has its own bounded queue with an overflow policy (drop the oldest, skip to the next key frame, or disconnect).

Frames are codec-agnostic: the crate moves bytes, a timestamp and a key flag, and never decodes them. Raw PCM needs no codec. Streams and frames carry optional opaque app metadata that the crate never reads, apart from the stage metadata described below.

Key types and modules

  • Publisher, Hub, MemorySource and Recording: live streams, recorded streams that play from the start or from a position, and arrival Stats (frames, loss, delay, jitter).
  • net: serve offers a Hub on a weirdnet-net node and asks a StreamAuth about each subscription; Subscriber connects to one.
  • clock: serve_clock and measure find another node’s clock offset (the exchange with the shortest round trip wins); DriftFit fits it over time for the offset at any moment and the drift in ppm.
  • remote (feature route): a weirdnet-audio-route executor for the connections between a weirdnet-audio-engine router and other nodes, with resampling, a playout level that follows the sender’s clock, aligned links and a per-link report. PeerTable tells it where nodes are.
  • transport: the follow-transport protocol. A master starts, stops, locates and sets the tempo of several instances with plain serde messages (Transport: Prepare, Ready, Start, Stop, Locate, Tempo, Beacon). A Follower learns the master’s session clock from them and tells its engine what to do on the right audio block (Action), and corrects drift without jumping over a hit. The app names the service and carries the messages.
  • stage and align: metadata saying where on the sender’s loop each frame belongs (StageStreamMeta, LoopMarker), a Grid to place it on yours at any sample rate, and where a collaborator’s audio plays on your loop: recorded takes in place, live audio in whole bars, or immediately.
  • bus, listen, along, clocked: the audio-thread tap and mix over lock-free rings, listen-along (a master out as a stream), record-along (your dry stream and take, and a collaborator’s played aligned to your loop), and a manual sink on its own clock.

Usage

[dependencies]
weirdnet-streaming = "0.1.0"

Where it fits

  • Builds on weirdnet-net.
  • Used by weirdnet-audio-stream, weirdnet-audio-record, SongNotes drum machine, SongNotes controller, SongNotes monitor, SongNotes collab.
  • Extracted from weirdnet-audio-stream and the SongNotes apps.
  • License: BSD-3-Clause.
Version 0.1.0 is on crates.io (docs.rs, repository). To move over from weirdnet-audio-stream, depend on weirdnet-streaming and write weirdnet_streaming where you wrote weirdnet_audio_stream; the 0.3 API is unchanged.