Skip to content

Examples

What each example in the streamlib repository shows, what it needs, and how its stream is wired. Every one ships with the runtime as a sample project.

The streamlib repository has twelve examples, each a small project that does one thing well: a GPU halftone, an object detector, a reverb, a lower third. Each is an ordinary project, a tatolab-project.json, a pyproject.toml and a graph document in streams/, and each ships with the runtime as a sample.

In Tato Studio, choose File › Marketplace…, find the sample, and press Clone sample: it becomes a project of your own, ready to play and change. Every example’s pictures are meant to be watched in Studio’s Node visualizer; none opens a window of its own.

From a terminal, start a project from one with tatolab new, then open its folder in Studio:

Terminal window
tatolab new my-halftone --sample camera-halftone
cd my-halftone
tatolab dev

Source. The camera, seen in the Node visualizer: the smallest useful stream, one CameraSource node and nothing else. It shows what a project is: a folder, its Python dependencies, and a graph document.

Needs: a camera.

Source · Source. The camera through a Slang compute kernel, in a process node: black and white in one, newsprint dots in the other. Each builds its kernel once in setup and dispatches it per frame, and the pixels never leave the GPU.

CameraSource → GrayscaleCompute (or HalftoneCompute)

Needs: a camera.

Source. A broadcast look built from six Python nodes: Slang glitch and film-grain kernels, MediaPipe pose tracking driving a ModernGL avatar, and a Skia overlay, composited on the GPU.

Needs: a camera. MediaPipe, ModernGL and Skia come from the project’s dependencies.

Source. One capture device in, two cameras out: “Tatolab Camera”, the camera untouched, and “Tatolab Camera Inverted”, after a Python node inverts its colours. Every app on the machine can pick either while the project plays.

CameraSource ─┬─▶ VirtualCameraSink ("Tatolab Camera")
└─▶ InvertingEffect ─▶ VirtualCameraSink ("Tatolab Camera Inverted")

Needs: Linux, a camera, and v4l2loopback or PipeWire. See Virtual camera.

Source. A live lower third and a Rive station bug over the camera, at 1080p60. A web page drawn by BrowserSource and a Rive animation drawn by RiveSource are layered over the camera by AlphaOverCompositor, and a data message swaps the lower third’s template without restarting anything.

CameraSource ─────────────────────────────────────▶ layer_0 ─┐
LowerThirdRundown ─ data ─▶ BrowserSource ────────▶ layer_1 ─┼─ AlphaOverCompositor
RiveSource ───────────────────────────────────────▶ layer_2 ─┘

Needs: a camera.

Source. The camera and microphone, encoded with H.264 and Opus, sent as one WHIP session with two tracks. Its publisher subclasses WhipPublisher to read the endpoint from the runtime’s environment, so the URL’s key is never in the graph document.

CameraSource ─▶ H264Encoder ─┐
├─▶ WhipPublisherToTheRuntimeEnvironmentsEndpoint
MicrophoneSource ─▶ OpusEncoder ─┘

Needs: a camera, a microphone, hardware H.264 encode, and a WHIP endpoint, such as Cloudflare Stream’s, in STREAMLIB_WHIP_URL. See WebRTC.

Source. The pipeline a small drone flies with, on a desk: the camera through a synthetic fisheye lens, then rectified by a compute kernel and run through an object detector, with the distorted and the corrected views both in the Node visualizer.

CameraSource ─▶ SyntheticFisheyeLens ─▶ UndistortingObjectDetector

Needs: a camera, and a PyTorch build that sees your GPU. See Use your model.

Source. The microphone through a reverb to the speaker: you hear yourself in a room that isn’t there. Its input asks for 10 ms mono windows, and the runtime converts whatever the microphone delivers.

MicrophoneSource ─▶ ReverbEffect ─▶ SpeakerSink

Needs: a microphone, a speaker, and headphones, or it feeds back.

Source. Three sine voices at three different sample rates and block sizes, one of them stereo, mixed into a C major chord. The mixer’s window contract does every conversion; there’s no resampler in its code.

ToneSource ×3 ─▶ ChordMixer ─▶ SpeakerSink

Needs: a speaker.

Source. The test pattern through a halftone lens kernel, then a CPU meter that logs its brightness once a second: pixels on the GPU, logic on the CPU, the two halves most streams have.

TestPatternSource ─▶ HalftoneLensEffect ─▶ BrightnessMeter

Needs: nothing: no camera and no display.

Source. One scene rendered twice and cut down the middle: rasterized on the left, ray traced on the right, with the same camera, geometry and shading, so the difference is what casting a ray buys.

RasterizedSceneRenderer ─┐
├─▶ SplitScreenCompositor
RayTracedSceneRenderer ──┘

Needs: a GPU with hardware ray tracing. See GPU effects.