Capture system speakers, isolate any single app/process, or mix microphones into one live PCM stream across Windows, Linux & macOS. Native WASAPI · PipeWire · PulseAudio · Core Audio Process Taps · ScreenCaptureKit — zero virtual audio cables, zero silent fallbacks.
Created by @s0d3s — author of PyAudioWPatch (140k+ monthly PyPI downloads, 340+ dependent repos) — released after nearly a year of ground-up safe-Rust engineering & polish.
Full Documentation & API Reference • Overview • Live TUI Demo • Drop-In Adapters Roadmap • Why Not PyAudioWPatch? • OS Support • Permissions • Docs Map
What Can You Capture?
capture-system-or-process-audio ( pip install capture-system-or-process-audio / cargo add capture-system-or-process-audio ) is a cross-platform native audio capture and live-mixing engine for Windows 10/11 ( WASAPI ), Linux ( PipeWire & PulseAudio ), and macOS ( Core Audio Process Taps & ScreenCaptureKit on Apple Silicon & Intel). Describe what audio you want, and receive decoded PCM frames ready for NumPy , faster-whisper / Whisper STT, OpenAI Realtime / LiveKit voice agents, WebRTC , Tauri / desktop apps, DSP, or file encoders — without installing VB-Cable, BlackHole, or Soundflower :
🔊 System / Speaker Loopback ( default_output , device ): Capture audio playing on the user's speakers or headphones — automatically following OS default-device switches ( follow default) or pinning a specific endpoint ( pin ).
🎯 Single Application or Process Tree ( find_app , process ): Isolate audio from just Zoom , Microsoft Teams , Google Meet (browser), Spotify , Firefox , or a game (including helper child processes where supported) without recording Discord notifications or unrelated apps.
🎙️ Microphones & Audio Inputs ( microphone , input_device ): Capture default or specific microphones with automatic sink-monitor exclusion and live device-switch tracking.
🎛️ Drift-Compensated Multi-Source Mixing + Format Conversion: Pass [microphone(), find_app("Zoom")] to receive one synchronized PCM stream converted on the fly ( 16 kHz mono f32 / i16 for faster-whisper & STT, 24 kHz i16 for Realtime Voice AI, or 48 kHz stereo f32 for WebRTC & studio recording) with zero steady-state heap allocations on read_into .
Prebuilt binary wheels ( cp311-abi3 , cp314t , and PEP 803 cp315-abi3.abi3t ) support CPython 3.11 – 3.15 plus Free-Threaded Python 3.14t & 3.15t ( -Xgil=0 ) across Windows ( x64 / ARM64 ), Linux ( x86_64 / aarch64 manylinux_2_28 ), and macOS ( Apple Silicon arm64 & Intel x86_64 ) with zero mandatory runtime dependencies and complete .pyi type stubs.
1. Capture default speakers (or isolate a single running application):
2. List, filter & use available CaptureTarget s deterministically:
cspa.find_app("Name") is a quick single-match helper, but real desktops often run multiple instances, localized names, or multiple USB headsets. Enumerate cspa.discover() to filter deterministically by active_audio , pid , executable_path , app_id , or device_id and pass selected CaptureTarget s straight into cspa.capture(...) :
3. Mix Microphone + Meeting App ( Zoom / Teams ) for faster-whisper , STT & Voice Agents:
📖 Python Docs: Python SDK Handbook • Python API Reference • Package README
The unified capture-system-or-process-audio facade crate enforces #![forbid(unsafe_code)] and automatically selects the native OS backend ( WASAPI , PipeWire / PulseAudio , or Core Audio / ScreenCaptureKit ) behind one single cross-platform API — ideal for Tauri desktop apps, native AI meeting assistants, real-time voice agents, and low-latency DSP engines.
📖 Rust Docs: Rust SDK Handbook • Rust API Reference • docs.rs • Crate README
⚙️ C++17 Quick Start (Header-Only RAII)
Download the prebuilt cspa-ffi- - archive from GitHub Releases containing include/cspa.hpp , include/cspa_experimental.h , shared libraries, and CspaConfig.cmake — ready for native desktop recorders, WebRTC media clients, game/broadcast overlays, and local whisper.cpp / voice-AI pipelines. Supports both C++ exceptions ( /EHsc , -fexceptions via *_or_throw() ) and exception-free builds ( /EHs-c- , -fno-exceptions via cspa::Result ).
📖 C++17 Docs: C++17 SDK Handbook • C++17 API Reference • CMake & FFI SDK README
🧩 C11 Quick Start (Stable FFI Boundary)
cspa_experimental.h provides a size- and schema-revision-checked C11 ABI ( cspa_abi_check ) with catch_unwind panic containment across every exported symbol and zero compile-time NEEDED links to libpipewire or libpulse on Linux — ideal for C host applications, audio plugins, game engines, and custom FFI bindings ( Go , Zig , C# , Swift ).
📖 C11 Docs: C11 ABI Handbook • C11 Functions & Structs Reference • FFI SDK README
Drop-In Ecosystem Adapters & Node.js SDK (Planned)
The library already connects cleanly to NumPy ( block.to_numpy(copy=False) ), PyAudio / wave ( memoryview(block) + OutputConverter ), faster-whisper ( 16 kHz mono f32 ), asyncio , Rust, and C/C++ pipelines.
Planned zero-rewrite drop-in compatibility adapters and Node.js / TypeScript / Electron bindings aim to let existing audio apps use system, per-application, or mixed mic+app capture without rewriting their consumer loops:
👉 Want early access to a specific adapter or the Node.js SDK? Star / Watch this repository or open an issue with your target stack!
Why This Exists — Beyond PyAudioWPatch
Four years ago I created PyAudioWPatch to bring Windows WASAPI speaker loopback to Python's PyAudio . Today it is a staple of the Python audio ecosystem — serving 140,000+ monthly PyPI downloads ( ~1.6M+ / year) and powering 340+ open-source repositories across AI meeting copilots, live Whisper/STT transcription bots, voice agents, and desktop recorders.
As PyAudioWPatch grew over 4+ years in production, users repeatedly requested features that were architecturally impossible to implement inside a legacy PortAudio C wrapper:
Per-application isolation & native macOS / Linux capture: PortAudio only models hardware endpoints — you could not isolate just Zoom , Spotify , or a game without recording Discord pings and desktop notifications too, while macOS and Linux users were still forced to manually install virtual audio drivers ( BlackHole , VB-Cable ).
Production loopback traps that break naive recorders: Silent WASAPI endpoints emit zero packets (causing blocking stream.read() loops in PyAudioWPatch to hang forever); unplugging or switching headphones breaks pinned streams; mixing [Microphone + System/App Output] drifts apart across independent hardware clocks; and Free-Threaded Python 3.14t / 3.15t ( -Xgil=0 ) collides with PortAudio's global C state.
Rather than piling fragile workarounds onto PyAudioWPatch , I spent nearly a year developing, testing, and polishing capture-system-or-process-audio from scratch in safe Rust — turning years of PyAudioWPatch user requests and edge-case lessons into one unified, zero-steady-state-allocation engine across Python, Rust, C++17, and C11 :
What single-OS process-tap wrappers ( proc-tap , catap , flexaudio ) or Electron desktopCapturer ? Single-platform and prototype wrappers lack unified Windows + PipeWire/PulseAudio + macOS Core Audio/ScreenCaptureKit coverage, cross-clock [Microphone + App] drift compensation, live target hot-swap, and free-threaded 3.14t / 3.15t zero-allocation read_into — while Electron desktopCapturer bundles heavyweight video capture pipelines without per-process isolation on Windows/Linux.
📊 Upcoming Cross-Platform Statistical Benchmarks: A standalone, reproducible cross-platform latency, tail-jitter ( p50 / p95 ), and zero-allocation benchmark suite comparing capture-system-or-process-audio head-to-head against existing audio capture libraries across Windows 11 ( WASAPI ) , Linux ( PipeWire & standalone PulseAudio ) , and macOS ( Core Audio Taps & ScreenCaptureKit ) will be published shortly.
📖 Migrating from PyAudioWPatch ? See the Side-by-Side PyAudioWPatch Migration Guide in the Python SDK Handbook.
📖 Migrating from PyAudioWPatch ? See the Side-by-Side PyAudioWPatch Migration Guide in the Python SDK Handbook.
Platform & Backend Matrix
Capabilities differ across operating systems. Core invariant: When a requested scope or capability is unsupported on the current OS or OS version, capture-system-or-process-audio fails explicitly with a typed error ( CapabilityError / PlanError ) — it never silently falls back from single-process capture to full-system audio.
Recording Permissions
Modern desktop operating systems gate audio capture behind user privacy consent — including macOS TCC ( Microphone , Core Audio SystemAudio taps, and ScreenCaptureKit ScreenRecording ) and Windows Microphone ConsentStore / Group Policy.
Interactive auto-request by default ( PermissionPolicy::AutoRequest ): Opening a capture session automatically prompts for required OS permissions on interactive desktop sessions.
Non-prompting preflight ( check_permissions & PermissionPolicy::CheckOnly / request_permissions=False ): Query an honest 5-state PermissionReport ( Granted , NotDetermined , Denied , Restricted , Unknown ) before opening any stream, without triggering modal OS dialogs in background services or CI.
macOS .app bundle SIGABRT protection: Detects missing NSMicrophoneUsageDescription / NSAudioCaptureUsageDescription keys in bundled Info.plist files before calling Apple frameworks and returns a clean PermissionDenied ( PermissionError in Python) instead of aborting the process.
Interactive Studio Demo
Explore live target discovery, per-source backend/gain controls, real-time CaptureRequest::inspect() execution plans, OS permission states, and live spectroscopes right in your terminal with cspa-tui-demo (prebuilt binaries in GitHub Releases , or built from source):
Live Picker ( A ): Browse Applications (parent-tree roll-up), Processes , Output Devices , and Microphones with live 256 -event discovery updates.
Record ( R ), Live Hot-Swap ( Space ) & Permissions ( K ): Start/stop RAM takes ( R ), toggle staged sources or gain ( G ) mid-recording without losing your active take, and inspect/request OS privacy permissions interactively.
3-Mode Spectroscope ( V ) & WAV Export ( W ): Switch between 2048-pt Hann FFT , Truecolor Waterfall , and Zero-Crossing Braille Oscilloscope (visual-only monitoring prevents microphone speaker feedback!), play back RAM takes ( P ), and export [Save WAV] on demand.
See tools/cspa-tui-demo/README.md and the Interactive Studio Demo Manual for all panels, modals, and shortcuts.
FAQ & Architecture Details
No. Every backend uses built-in OS audio APIs ( WASAPI on Windows, PipeWire / PulseAudio on Linux, Core Audio Process Taps and ScreenCaptureKit on macOS). Normal speaker and headphone playback continues uninterrupted.
On Windows WASAPI loopback and per-process taps, the OS emits zero packets while no audio is playing. By default, single-stream reads wait cleanly until audio resumes (or until timeout_ms elapses). When feeding consumers that expect continuous wall-clock frames (such as VADs, PyAudio -style loops, or WebRTC/Discord streams), pass silence_on_idle=True (Python) or MixerConfig { silence_on_idle: true, .. } (Rust/C++) to synthesize metadata-flagged silent frames ( synthesized_silence = true ) while idle.
Yes. Architecture follows a strict four-layer invariant: Backends capture. Core orders and buffers. Manager plans, monitors, mixes, and reopens sessions. Adapters adapt. Native acquisition callbacks write into preallocated bounded slot pools ( StorageBudget ) without unbounded allocation or locks, CspaMixer aligns independent hardware clocks within < 10 ms best-effort relative skew, and warmed read_into loops perform 0 heap allocations in steady state across Rust, Python (including -Xgil=0 free-threading), C++17, and C11.
Yes. Call cspa.request(targets).inspect() (Python), request(targets).inspect() (Rust), or req.inspect() (C++) for a side-effect-free CapturePlanReport showing per-target backend resolution, session combine strategy ( PassThrough , SharedNativeGraphMix , or CspaMixer ), active stream count, and estimated PCM memory footprint.
Documentation & Guides
Full user manuals, architecture deep-dives, and 100%-symbol API references are hosted at s0d3s.github.io/capture-system-or-process-audio :
Dual-licensed under either of:
Apache License, Version 2.0 ( LICENSE-APACHE or )
MIT License ( LICENSE-MIT or )
at your option. Prebuilt Linux binaries dynamically load system libpipewire-0.3.so.0 and libpulse.so.0 at runtime without bundling or statically linking LGPL libraries; see each package's THIRD_PARTY_NOTICES.md for dependency attributions.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
