Project 5: Audio Routing Graph (Like JACK)

A low-latency audio routing system where applications connect to named ports and you can wire any output to any input dynamically.

Quick Reference

Attribute Value
Primary Language See main guide
Alternative Languages N/A
Difficulty Expert
Time Estimate 2-3 months
Knowledge Area See main guide
Tooling See main guide
Prerequisites Strong C/C++ or Rust, threading experience, completed Project 1 or 3

What You Will Build

A low-latency audio routing system where applications connect to named ports and you can wire any output to any input dynamically.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Designing a port/connection graph data structure
  • Implementing lock-free communication between audio and control threads
  • Processing the graph in the audio callback without blocking
  • Achieving consistent low latency (< 10ms)

Key Concepts

  • (consolidated from all projects above):
  • Kernel/User Interface: “Linux Device Drivers” + “The Linux Programming Interface”
  • Real-time Audio: Study PipeWire and JACK source code
  • IPC Protocols: Design your own audio transport protocol
  • System Integration: Making all pieces work together seamlessly

Real-World Outcome

# Start your routing server
$ ./audio_graph_server --latency 5ms --sample-rate 48000

╔═══════════════════════════════════════════════════════════════════╗
║              Audio Graph Server v1.0                               ║
║              Low-Latency Audio Routing System                      ║
╠═══════════════════════════════════════════════════════════════════╣
║ Sample Rate: 48000 Hz                                              ║
║ Buffer Size: 256 frames (5.33 ms)                                  ║
║ Format: 32-bit float                                               ║
║ Real-time Priority: SCHED_FIFO (priority 80)                       ║
║ Memory locked: 512 MB                                              ║
╠═══════════════════════════════════════════════════════════════════╣
║ Server ready. Listening on /tmp/audio_graph.sock                   ║
╚═══════════════════════════════════════════════════════════════════╝

[INFO] Audio callback thread started
[INFO] Graph processing thread running at RT priority

Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: AUDIO_SOUND_DEVICES_OS_LEARNING_PROJECTS.md
  • Primary references are listed in the main guide