# weirdnet-streaming
[](https://crates.io/crates/weirdnet-streaming)
[](https://docs.rs/weirdnet-streaming)
Streaming for Weirdnet: live and recorded audio streams between nodes, the transport that keeps several players together, and the loop-positioned streams that apps record along with. It is the one crate for all of it, and the successor to `weirdnet-audio-stream`.
Part of [Weirdnet](https://net.weirdbrains.com) by [Weird Brains](https://weirdbrains.com). BSD-3-Clause.
## What it does
**Streams**
- **Publish and subscribe**: a `Publisher` sends frames of one stream to any number of listeners, in process or over the network. `send` never blocks; each listener has its own bounded queue with an overflow policy (drop oldest, skip to the next key frame, or disconnect), so a slow listener never slows the others.
- **Live and recorded**: a late live listener starts at the next key frame; a recorded stream (`Recording` into a `MemorySource`) plays from the start or from a position.
- **Codec-agnostic**: frames carry bytes, a timestamp in ticks of the stream's clock and a key flag; raw PCM works with no codec (`StreamInfo::pcm_f32`, `Frame::pcm_f32`).
- **Over Weirdnet**: `net::serve` offers a `Hub` of streams on a weirdnet-net node, asking a `StreamAuth` about each subscription; `net::Subscriber` connects to one and keeps `Stats` (frames, loss, arrival delay, jitter).
- **Clocks**: `clock::serve_clock` and `clock::measure` find another node's clock offset; `clock::DriftFit` fits it over time for the drift in ppm.
- **Remote routing** (feature `route`): `remote::RemoteExecutor` is a [weirdnet-audio-route](https://crates.io/crates/weirdnet-audio-route) executor for the connections between a [weirdnet-audio-engine](https://crates.io/crates/weirdnet-audio-engine) router and other nodes, with resampling, drift following and aligned links; `remote::PeerTable` tells it where nodes are.
**Transport**
- `transport`: a master starts, stops, locates and sets the tempo of several instances. Messages (`Transport`) are plain serde values; a `Follower` learns the master's session clock from them and tells its engine (`Action`) what to do on the right audio block, and corrects drift without jumping over a hit.
**Loop-positioned streams (record-along)**
- `stage`: stream and frame metadata saying where on the sender's loop each frame belongs, and `Grid` to place it on yours at any sample rate.
- `align`: where a collaborator's audio plays on your loop (a take in place, live in whole bars, or immediate).
- `bus`: the audio-thread side, a tap and a mix over lock-free rings.
- `listen` and `along`: the network side, listen-along (a master out as a stream) and record-along (your dry stream and take, and a collaborator's played aligned to your loop).
- `clocked`: a manual sink on its own clock, to run without a device or to inject drift in tests.
```sh
cargo run --example tone
cargo run --example transport
```
The wire format is a length-prefixed message per frame on one weirdnet-net stream (see the `wire` module).
## Coming from weirdnet-audio-stream
`weirdnet-audio-stream` 0.4 re-exports this crate and is deprecated. Replace the dependency with `weirdnet-streaming` and `weirdnet_audio_stream` with `weirdnet_streaming`; the 0.3 API is unchanged.