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,MemorySourceandRecording: live streams, recorded streams that play from the start or from a position, and arrivalStats(frames, loss, delay, jitter).net:serveoffers aHubon a weirdnet-net node and asks aStreamAuthabout each subscription;Subscriberconnects to one.clock:serve_clockandmeasurefind another node’s clock offset (the exchange with the shortest round trip wins);DriftFitfits it over time for the offset at any moment and the drift in ppm.remote(featureroute): 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.PeerTabletells 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). AFollowerlearns 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.stageandalign: metadata saying where on the sender’s loop each frame belongs (StageStreamMeta,LoopMarker), aGridto 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.
weirdnet-streaming and write weirdnet_streaming where you wrote weirdnet_audio_stream; the 0.3 API is unchanged.