Installation
capture-system-or-process-audio selects the active OS backend (WASAPI, PipeWire/PulseAudio, or Core Audio/ScreenCaptureKit) in one single place behind a 100% platform-agnostic safe-Rust API (#![forbid(unsafe_code)]) — your application crate never needs per-OS #[cfg] backend dispatch.
Quick Start
1. Capture Default Speakers & Zero-Allocation read_into
use ;
use Duration;
2. List, Filter & Capture CaptureTargets Deterministically (discover_query)
Discovery::find_app("Name", ...) is a single-match shortcut that fails if multiple instances run or display names differ across locales/packaging. Enumerating discover_query lets you inspect every available CaptureTarget (applications, processes, output_devices, input_devices), filter deterministically on active_audio(), pid(), app_id(), executable_path(), or clean_device_id(), refine with .with_gain(...) / .with_backend(...), and pass the selected targets directly into CaptureManager:
use ;
use Duration;
3. Mix Microphone + Single Application at 16 kHz Mono I16
use ;
use ;
4. Check & Request OS Recording Permissions
use ;
use Duration;
Choosing Between CaptureManager and AudioStream
CaptureManager(capture,capture_single,CaptureManager::open) — Recommended Default: Uses a zero-extra-copyPassThroughpath for single targets while owning multi-target native graph fan-in (SharedNativeGraphMix), drift-compensated software mixing (CspaMixer+ pre-mixInputNormalizer + FrameReblocker), post-mixOutputConverter, automaticFollowdefault-device switching,OnRootExit::Waitrelaunch tracking, and live two-tierupdate_targets(...)hot-swap.AudioStream(open_stream,AudioStream::open) — Lightweight Single Session: Owns a single native backend capture stream directly when you explicitly want zero discovery subscriptions, process-tree monitoring, or device-switch transitions.
Platform & Native Backend Matrix
Unsupported scopes or OS versions fail explicitly with CapabilityError — never silently broadening from single-process capture to full-system loopback:
| Platform | Crate Backend | Supported Targets & Capabilities | Runtime Notes |
|---|---|---|---|
Windows 10 / 11 (x86_64, aarch64) |
capture-system-or-process-audio-windows (WASAPI) |
default_output & microphone (Follow/Pin), device & input_device (>= 19041); process & application ProcessScope::Tree (>= 20348). |
ProcessScope::Exact rejects explicitly (CapabilityError::UnsupportedScope). |
Linux (x86_64, aarch64) |
capture-system-or-process-audio-linux (PipeWire 0.3.65+, PulseAudio 15.0+) |
Output endpoints, microphones (.monitor sinks excluded), PipeWire SharedNativeGraphMix virtual-sink fan-in, PulseAudio per-stream CspaMixer, and [PipeWire + PulseAudio] cross-backend mixing. |
Loads libpipewire-0.3.so.0 & libpulse.so.0 via dlopen (0 compile-time NEEDED links). |
macOS (aarch64-apple-darwin) |
capture-system-or-process-audio-macos (Core Audio, ScreenCaptureKit) |
Core Audio Process Taps (macOS 14.2+), Core Audio HAL microphone input (macOS 13.0+), ScreenCaptureKit application (ProcessScope::Exact, macOS 13.0+), and [SCK + CoreAudio] cross-backend mixing. |
Intel macOS (x86_64) and SCK ProcessScope::Tree reject explicitly. |
Repository, Other SDKs & License
- Official Documentation, Manuals & Multi-SDK Reference: https://s0d3s.github.io/capture-system-or-process-audio/
- GitHub Repository (Python, C++17, C11 SDKs &
cspa-tui-demo): https://github.com/s0d3s/capture-system-or-process-audio - License: Dual-licensed under MIT or Apache-2.0, at your option.