Skip to content

Votline/Replay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Replay

image

Replay is a high-performance system audio recorder and player written in Go. It captures system audio output (loopback), compresses it in real-time using a hybrid Opus+Zstd pipeline, and provides a custom OpenGL-based GUI for managing playback segments.

🚀 Key Features

  • System Loopback Recording: Automatically routes system audio (what you hear) to the recorder via PulseAudio monitor sources.

  • High-Efficiency Compression: Implements a two-stage compression pipeline:

  • Opus: For perceptual audio coding.

  • Zstd: For additional lossless compression of the bitstream.

  • Custom Audio Engine:

  • Low-latency I/O using PortAudio.

  • Lock-free Ring Buffers using atomic operations for thread-safe data transfer.

  • Hardware Accelerated UI:

  • Built from scratch using OpenGL 4.1 Core.

  • Custom shader pipeline (GLSL) for rendering UI elements.

  • No heavy UI frameworks — pure vertices and textures.

🛠 Tech Stack

  • Language: Go (Golang)
  • Audio I/O and Compression: Go-audio (Votline/Go-audio)
  • Graphics: OpenGL 4.1 (go-gl), GLFW
  • System Integration: PulseAudio (pactl CLI wrappers for routing)

🧠 Architecture Highlights

graph TD
    UI([GLFW Transparent Window]) <-->|Mouse Events / Shaders| HV[HomeView State Machine]
    HV -->|Control: Record / Play| AC[AudioClient Wrapper]
    HV -->|Manages 3 Slots Offset| File[(.rep Session File)]
    AC <-->|Direct Stream I/O via Section R/W| File
Loading

The Audio Pipeline

The application avoids GC pauses and blocking operations in the audio callback thread by utilizing a custom Ring Buffer implementation (internal/buffer).

  1. Capture: Audio frames are captured via PortAudio.
  2. Buffering: Raw PCM data is written to a lock-free Ring Buffer (buffer.go) using sync/atomic to manage read/write pointers safe across goroutines.
  3. Processing: A separate goroutine drains the buffer, encodes audio chunks into Opus frames, and wraps them in Zstd for storage efficiency.
  4. Storage: Data is written to disk in a custom binary format capable of handling multiple audio segments within a single file.

The Rendering Engine

Instead of using standard widgets, the UI is rendered directly via the GPU:

  • Shaders: Custom Vertex and Fragment shaders handle texture mapping and color blending (shaders.go).
  • Event Loop: Integrated with GLFW for handling mouse inputs and window events, manually mapping cursor coordinates to normalized device coordinates (NDC) for UI interaction.

📦 Usage

Prerequisites

  • Linux (Due to pactl dependency for loopback routing)
  • OpenGL drivers

Running

GUI Mode:

./replay ui session.rep

CLI Mode:

# Record strictly via CLI
./replay record music.rep

# Replay strictly via CLI
./replay replay music.rep

📝 Controls

  • Record: Start capturing system audio.
  • Stop: Finalize the current segment.
  • Play/Pause: Playback the recorded segment.
  • Prev/Next: Navigate between recorded segments (if multiple recordings exist in one session).

⚠️ Disclaimer

This project relies on pactl (PulseAudio Control) for automatic monitor source routing. It is designed primarily for Linux environments using PulseAudio or PipeWire-Pulse.

Licenses

This project is distributed under the MIT License. See the LICENSE file for details.

Third-party LICENSES

About

High-performance system audio recorder & player. Features a custom OpenGL UI, lock-free ring buffers (sync/atomic), and a real-time Opus+Zstd compression pipeline. Low-latency, zero-dependency audio I/O in Go.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages