Skip to main content

Crate weirdnet_streaming

Crate weirdnet_streaming 

Source
Expand description

Streaming for Weirdnet: audio streams between nodes, the transport that keeps them together, and the loop-positioned streams apps record along with.

Streams (the core, moved here from weirdnet-audio-stream)

  • A Publisher sends Frames of one stream to any number of listeners. It never blocks: each listener has its own bounded queue and an Overflow policy, so a slow listener never slows the others.
  • A late live listener starts at the next key frame; a MemorySource holds a recorded stream that listeners can seek in.
  • Frames are codec-agnostic: the crate moves bytes and a CodecId and never decodes. Raw PCM needs no codec (StreamInfo::pcm_f32). Streams and frames carry optional opaque app metadata that the crate never reads.
  • net serves a Hub of streams over weirdnet-net streams, with an authoriser per subscription, and net::Subscriber connects to one, with Stats on arrival delay, jitter and loss.
  • clock: another node’s clock offset by request and reply, and its drift by a line fit.
  • remote (feature route): a weirdnet-audio-route executor carrying connections between a weirdnet-audio-engine router and other nodes, with resampling, drift following and measured delay, and a remote::PeerTable to tell it where nodes are.

Transport

  • transport: the follow-transport protocol (Prepare, Ready, Start, Stop, Locate, Tempo, Beacon), the transport::SessionClock an instance learns from a master’s messages, and the transport::Follower that turns them into engine actions on the right audio block. It is a plain message type: the app chooses how to carry it.

Loop-positioned streams (record-along)

  • stage: stream and frame metadata saying where on the sender’s loop each frame belongs, and stage::Grid to turn that into the listener’s own frames at any sample rate.
  • align: where a collaborator’s audio plays on your loop (recorded exact, live bar-aligned or immediate).
  • bus: the audio-thread side, a tap and a mix that never lock or allocate in the render callback.
  • listen and along: the network side, listen-along (a master out as a stream) and record-along (a dry stream and take, and playing a collaborator’s aligned to your loop).
  • clocked: a manual sink on its own clock, to run without a device or to inject drift in tests.

Re-exports§

pub use net::AllowAll;
pub use net::Hub;
pub use net::StreamAuth;

Modules§

align
The stream input’s aligner: where each collaborator’s audio plays on your loop.
along
Record-along on the network: your dry stream (your own voices, each frame stamped with its loop position), your last loop as a stamped recorded take, and playing a collaborator’s take or live dry stream aligned to your loop.
bus
The audio side of listen-along, safe on the audio thread: a wrapper around the engine’s render callback that copies the master out into a ring (the tap, read by the network side to stream it) and adds samples from another ring (the mix, filled by a subscription to someone else’s master out). No locks and no allocation in the callback.
clock
How far another node’s clock is from this one’s, and how fast the gap grows.
clocked
A manual sink on its own clock: a thread that calls the render callback once per block at the pace of a device whose clock runs drift_ppm fast (or slow, when negative) against the monotonic clock. Used for instances whose output is none, and in tests to inject drift.
listen
Listen-along: the host streams its master out as raw PCM (32-bit float) over weirdnet-streaming; members of the session subscribe and hear it mixed into their own output. Each frame carries the sender’s wall-clock time (frame metadata, 8 bytes, microseconds since the Unix epoch) so a listener can measure the one-way delay when the clocks agree (same machine, or synced clocks). The take is kept and offered as a recorded stream that can be played from any position.
net
Streams over weirdnet-net: a Hub served on a node, and a Subscriber to one stream.
remote
A remote executor (feature route): the connections of a weirdnet_audio_route graph between this node’s weirdnet_audio_engine router and other nodes.
stage
Stage stream metadata (record-along): what a stream is, and where on the sender’s loop each frame belongs. The stream crate carries both as opaque bytes.
transport
Follow-transport: a headless master starts, stops, moves and paces several instances so they play on one session time.
wire
The wire format: length-prefixed messages on one weirdnet-net stream.

Structs§

BufferPolicy
How much a listener may queue.
CodecId
An opaque codec name, for the decoder; never interpreted here.
Frame
One frame of a stream.
Listener
The receiving side of one in-process subscription. Dropping it leaves the stream.
ListenerInfo
One listener as the publisher sees it.
MemorySource
A recorded stream held in memory.
Publisher
The sending side of one stream. Cheap to clone; clones share the stream.
Recording
Collects a live stream’s frames into a MemorySource.
Stats
What a subscriber has seen: frames, loss, and how late and how unevenly frames arrive.
StreamId
A stream’s id, unique within its publisher’s hub.
StreamInfo
What a stream is.
SubscribeOptions
How to subscribe.

Enums§

Overflow
What happens when a listener’s queue is full.
Start
Where a subscription starts.
StreamError
Why a stream call failed.
StreamEvent
What a listener receives.
StreamKind
Live (frames as they are produced) or recorded (finite, seekable).

Constants§

PCM_F32LE
Raw PCM, 32-bit float, little endian, interleaved.
PCM_S16LE
Raw PCM, signed 16-bit, little endian, interleaved.

Traits§

FrameSource
A recorded stream a server can play to subscribers.