---
title: "Examples"
description: "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."
type: "docs-page"
url: "https://tatolab.com/docs/examples"
site: "Tatolab"
section: "Examples"
---

# 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](https://github.com/tatolab/streamlib/tree/main/examples) 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:

```sh
tatolab new my-halftone --sample camera-halftone
cd my-halftone
tatolab dev
```

## Camera

### camera-display

[Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-display). 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.

### camera-compute-kernel and camera-halftone

[Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-compute-kernel) · [Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-halftone). 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.

```txt
CameraSource → GrayscaleCompute (or HalftoneCompute)
```

**Needs:** a camera.

### camera-python-effects

[Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-python-effects). 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.

### camera-virtual-camera

[Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-virtual-camera). 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.

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

**Needs:** Linux, a camera, and v4l2loopback or PipeWire. See [Virtual camera](https://tatolab.com/docs/build/virtual-camera).

### lower-third

[Source](https://github.com/tatolab/streamlib/tree/main/examples/lower-third). 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.

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

**Needs:** a camera.

## Publishing

### camera-webrtc-publish

[Source](https://github.com/tatolab/streamlib/tree/main/examples/camera-webrtc-publish). 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.

```txt
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](https://tatolab.com/docs/build/webrtc).

## Models

### fisheye-object-detection

[Source](https://github.com/tatolab/streamlib/tree/main/examples/fisheye-object-detection). 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.

```txt
CameraSource ─▶ SyntheticFisheyeLens ─▶ UndistortingObjectDetector
```

**Needs:** a camera, and a PyTorch build that sees your GPU. See [Use your model](https://tatolab.com/docs/build/models).

## Audio

### microphone-reverb-speaker

[Source](https://github.com/tatolab/streamlib/tree/main/examples/microphone-reverb-speaker). 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.

```txt
MicrophoneSource ─▶ ReverbEffect ─▶ SpeakerSink
```

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

### audio-mixer-demo

[Source](https://github.com/tatolab/streamlib/tree/main/examples/audio-mixer-demo). 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.

```txt
ToneSource ×3 ─▶ ChordMixer ─▶ SpeakerSink
```

**Needs:** a speaker.

## GPU and patterns

### test-pattern-halftone-lens

[Source](https://github.com/tatolab/streamlib/tree/main/examples/test-pattern-halftone-lens). 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.

```txt
TestPatternSource ─▶ HalftoneLensEffect ─▶ BrightnessMeter
```

**Needs:** nothing: no camera and no display.

### raytracing-showcase

[Source](https://github.com/tatolab/streamlib/tree/main/examples/raytracing-showcase). 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.

```txt
RasterizedSceneRenderer ─┐
                         ├─▶ SplitScreenCompositor
RayTracedSceneRenderer ──┘
```

**Needs:** a GPU with hardware ray tracing. See [GPU effects](https://tatolab.com/docs/build/gpu-effects#graphics-and-ray-tracing-kernels).
