Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

szync is a lightweight, high-performance C++ utility for Windows that captures system audio in real-time and routes it to multiple playback devices simultaneously with ultra-low latency and automatic clock-drift correction.

🔍 How It Works & Pipeline

%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#1e1e2e', 'primaryTextColor': '#cdd6f4', 'primaryBorderColor': '#89b4fa', 'lineColor': '#a6adc8', 'secondaryColor': '#181825', 'tertiaryColor': '#11111b'}}}%%
graph TD
    %% Node Definitions
    Capture["Windows System Audio Capture<br/>(WASAPI Loopback / Process Filter)"]:::capture
    
    subgraph Engine ["szync Core Routing Engine"]
        Coordinator["Audio Coordinator"]:::coordinator
        Buffer1["Lock-Free SPSC Ring Buffer 1"]:::buffer
        Buffer2["Lock-Free SPSC Ring Buffer 2"]:::buffer
        BufferN["Lock-Free SPSC Ring Buffer N"]:::buffer
    end
    
    subgraph Threads ["Real-time MMCSS Render Threads"]
        Render1["Render Loop 1<br/>Resampler / Channel Map / DSP"]:::render
        Render2["Render Loop 2<br/>Resampler / Channel Map / DSP"]:::render
        RenderN["Render Loop N<br/>Resampler / Channel Map / DSP"]:::render
    end
    
    subgraph Output ["Playback Hardware Devices"]
        Dev1["Wired Headphones"]:::hardware
        Dev2["Bluetooth Speaker"]:::hardware
        DevN["USB DAC / Interface"]:::hardware
    end
    
    %% Flows
    Capture -->|Raw Float PCM Samples| Coordinator
    Coordinator -->|Lock-Free Push| Buffer1
    Coordinator -->|Lock-Free Push| Buffer2
    Coordinator -->|Lock-Free Push| BufferN
    
    Buffer1 -->|Lock-Free Pop| Render1
    Buffer2 -->|Lock-Free Pop| Render2
    BufferN -->|Lock-Free Pop| RenderN
    
    Render1 -->|Active Volume & Clock Correct| Dev1
    Render2 -->|Active Volume & Clock Correct| Dev2
    RenderN -->|Active Volume & Clock Correct| DevN

    %% Styling classes
    classDef capture fill:#1e1e2e,stroke:#f5c2e7,stroke-width:2px,color:#cdd6f4;
    classDef coordinator fill:#313244,stroke:#89b4fa,stroke-width:2px,color:#cdd6f4;
    classDef buffer fill:#1e1e2e,stroke:#a6e3a1,stroke-width:2px,color:#cdd6f4;
    classDef render fill:#313244,stroke:#f9e2af,stroke-width:2px,color:#cdd6f4;
    classDef hardware fill:#181825,stroke:#94e2d5,stroke-width:2px,color:#cdd6f4;
Loading
  • Real-time Capture: Uses event-driven Windows WASAPI loopback capture (either system-wide or isolated by application process).
  • Lock-Free Buffering: Audio is routed via single-producer single-consumer (SPSC) ring buffers running on high-priority MMCSS (Pro Audio) threads.
  • Clock-Drift Correction: Active occupancy monitoring skips frames dynamically to avoid buffer overflows and stutters between hardware devices.
  • Automatic Resampling: Built-in linear resampler and channel mapper handle format conversion automatically if the device driver doesn't support it natively.

🎨 Control Panel Features

The D3D11-accelerated dark-mode GUI manages everything dynamically:

  1. Multi-Device Routing Matrix: Toggle outputs dynamically.
  2. Custom Aliasing & Volumes: Rename devices inline and control volumes.
  3. Application Process Filters: Isolate audio captures to specific apps.
  4. Auto-Saving: Saves all changes instantly to %APPDATA%\szync\szync_config.ini.

🛠️ How to Build and Run

Prerequisites

  • Windows 10 / 11
  • MinGW-w64 (GCC) compiler toolchain (with g++ added to your system PATH).

Build Steps

  1. Double-click build.bat or run it from a terminal to compile szync.exe.
  2. Run szync.exe in the root folder.
  • Alternatively, download pre-compiled versions from the Releases section.

⚙️ Project Structure

szync/
├── build.bat                   # Compilation script
├── README.md                   # Project documentation
├── src/
│   ├── main.cpp                # Win32 & DirectX11 ImGui rendering loop
│   ├── audio_engine.h          # Real-time capture & routing logic
│   ├── config_manager.h        # INI settings manager
│   └── process_utils.h         # Process helper functions
└── thirdparty/imgui/           # User interface library

📄 License

Open-source under the MIT License.

About

A lightweight, high-performance C++ utility to mirror and route Windows system audio to multiple playback devices simultaneously with low latency.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages