# alexanderpach/low-latency-audio-pipeline architecture

> Architecture diagram of the GitHub repository alexanderpach/low-latency-audio-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexanderpach/low-latency-audio-pipeline
- Repository: https://github.com/alexanderpach/low-latency-audio-pipeline

## Overview

LLAP generates a 440 Hz sine wave on a producer thread, publishes samples to a lock-free single-producer/single-consumer ring buffer, and uses miniaudio’s playback callback to consume them for the audio device. The user starts and stops this runtime through the console. The graph preserves the audio backend and the queue’s cache-line support; miniaudio’s implementation was not sampled, so its internal behavior is not expanded here.

Main entry points: [`LLAP.cpp`](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/LLAP.cpp) (Pipeline runtime), [`audio_engine.h`](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/audio_engine.h) (Audio engine), [`SPSCDisruptor.cpp`](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/SPSCDisruptor.cpp) (SPSC ring buffer), [`miniaudio.h`](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/miniaudio.h) (Miniaudio backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Runtime control"]
  node_runtime["Pipeline runtime<br/>[LLAP.cpp]"]
  node_producer["Tone producer<br/>[LLAP.cpp]"]
end

subgraph group_audio["Audio playback"]
  node_engine["Audio engine<br/>[audio_engine.h]"]
  node_miniaudio["Miniaudio backend<br/>[miniaudio.h]"]
end

subgraph group_buffer["Lock-free buffer"]
  node_queue["SPSC ring buffer<br/>[SPSCDisruptor.cpp]"]
  node_cache["Cache-line support<br/>[disruptor.h]"]
end

node_user(("Console user"))
node_device["Audio device"]

node_user -->|"starts and stops"| node_runtime
node_runtime -->|"launches thread"| node_producer
node_runtime -->|"creates and controls"| node_engine
node_runtime -->|"gets queue"| node_engine
node_producer -->|"publishes samples"| node_queue
node_engine -->|"consumes samples"| node_queue
node_engine -->|"configures playback"| node_miniaudio
node_miniaudio -->|"outputs audio"| node_device
node_queue -->|"uses cache-line size"| node_cache

click node_runtime "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/LLAP.cpp"
click node_producer "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/LLAP.cpp"
click node_engine "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/audio_engine.h"
click node_miniaudio "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/miniaudio.h"
click node_queue "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/SPSCDisruptor.cpp"
click node_cache "https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/disruptor.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime,node_producer,node_user toneBlue
class node_engine,node_miniaudio toneAmber
class node_queue,node_cache toneMint
class node_device toneIndigo
```

## Components

### Runtime control

- [Pipeline runtime](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/LLAP.cpp): `LLAP.cpp`
- [Tone producer](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/LLAP.cpp): `LLAP.cpp`

### Audio playback

- [Audio engine](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/audio_engine.h): `audio_engine.h`
- [Miniaudio backend](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/miniaudio.h): `miniaudio.h`

### Lock-free buffer

- [SPSC ring buffer](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/SPSCDisruptor.cpp): `SPSCDisruptor.cpp`
- [Cache-line support](https://github.com/alexanderpach/low-latency-audio-pipeline/blob/master/disruptor.h): `disruptor.h`

### Other components

- **Console user**
- **Audio device**

## Connections

- Console user → Pipeline runtime: starts and stops (evidence: `LLAP.cpp`)
- Pipeline runtime → Tone producer: launches thread (evidence: `LLAP.cpp`)
- Pipeline runtime → Audio engine: creates and controls (evidence: `LLAP.cpp`)
- Pipeline runtime → Audio engine: gets queue (evidence: `LLAP.cpp`)
- Tone producer → SPSC ring buffer: publishes samples (evidence: `LLAP.cpp`)
- Audio engine → SPSC ring buffer: consumes samples (evidence: `audio_engine.h`)
- Audio engine → Miniaudio backend: configures playback (evidence: `audio_engine.h`)
- Miniaudio backend → Audio device: outputs audio (evidence: `README.md`)
- SPSC ring buffer → Cache-line support: uses cache-line size (evidence: `SPSCDisruptor.cpp`)
