Skip to main content

Cross-platform process-level audio capture library

Project description

๐Ÿ“ก ProcTap

Cross-Platform Per-Process Audio Capture

PyPI version Python versions Downloads Platform

Build wheels License: MIT Code style GitHub stars


ProcTap is a Python library for per-process audio capture with platform-specific backends.

Capture audio from a specific process only โ€” without system sounds or other app audio mixed in. Ideal for VRChat, games, DAWs, browsers, and AI audio analysis pipelines.

Platform Support

Platform Status Backend Notes
Windows โœ… Fully Supported WASAPI (C++ native) Windows 10/11 (20H1+)
Linux โœ… Fully Supported PipeWire Native / PulseAudio Per-process isolation, auto-fallback (v0.4.0+)
macOS ๐Ÿงช Experimental Core Audio Process Tap macOS 14.4+ (Sonoma) required

* Linux is fully supported with PipeWire/PulseAudio (v0.4.0+). macOS support is experimental (see requirements).


๐Ÿš€ Features

  • ๐ŸŽง Capture audio from a single target process (VRChat, games, browsers, Discord, DAWs, streaming tools, etc.)

  • ๐ŸŒ Cross-platform architecture โ†’ Windows (fully supported) | Linux (fully supported, v0.4.0+) | macOS (experimental, 14.4+)

  • โšก Platform-optimized backends โ†’ Windows: ActivateAudioInterfaceAsync (modern WASAPI) โ†’ Linux: PipeWire Native API / PulseAudio (fully supported, v0.4.0+) โ†’ macOS: Core Audio Process Tap API (macOS 14.4+)

  • ๐Ÿงต Low-latency, thread-safe audio engine โ†’ 44.1 kHz / stereo / 16-bit PCM format (Windows)

  • ๐Ÿ Python-friendly high-level API

    • Callback-based streaming
    • Async generator streaming (async for)
  • ๐Ÿ”Œ Native extensions for high-performance โ†’ C++ extension on Windows for optimal throughput


๐Ÿ“ฆ Installation

From PyPI:

pip install proc-tap

Platform-specific dependencies are automatically installed:

  • Windows: No additional dependencies
  • Linux: pulsectl is automatically installed, but you also need system packages:
    # Ubuntu/Debian
    sudo apt-get install pulseaudio-utils
    
    # Fedora/RHEL
    sudo dnf install pulseaudio-utils
    

Optional: High-Quality Audio Resampling (74% faster / 3.8x speedup for sample rate conversion):

pip install proc-tap[hq-resample]

Performance: With libsamplerate, resampling achieves 0.66ms per 10ms chunk (vs 2.6ms with scipy-only).

Compatibility Notes:

  • โœ… Python 3.10-3.12: Works on all platforms
  • โœ… Linux/macOS + Python 3.13+: Should work (you can try it!)
  • โš ๏ธ Windows + Python 3.13+: May fail to build (as of 2025-01)
    • If it fails, the library automatically falls back to scipy's polyphase filtering
    • Still provides excellent audio quality, just 74% slower for resampling
    • You can still try installing - if it works, great! If not, no harm done.

๐Ÿ“š Read the Full Documentation for detailed guides and API reference.

From TestPyPI (for testing pre-releases):

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ proctap

From Source:

git clone https://github.com/m96-chan/ProcTap
cd ProcTap
pip install -e .

๐Ÿ›  Requirements

Windows (Fully Supported):

  • Windows 10 / 11 (20H1 or later)
  • Python 3.10+
  • WASAPI support
  • No admin privileges required

Linux (Fully Supported - v0.4.0+):

  • Linux with PulseAudio or PipeWire
  • Python 3.10+
  • Auto-detection: Automatically selects best available backend
  • Native PipeWire API (recommended):
    • libpipewire-0.3-dev: sudo apt-get install libpipewire-0.3-dev
    • Ultra-low latency: ~2-5ms
    • Auto-selected when available
  • PipeWire subprocess:
    • pw-record: install with sudo apt-get install pipewire-media-session
  • PulseAudio fallback:
    • pulsectl library: automatically installed
    • parec command: sudo apt-get install pulseaudio-utils
  • โœ… Per-process isolation using null-sink strategy
  • โœ… Graceful fallback chain: Native โ†’ PipeWire subprocess โ†’ PulseAudio

macOS (Experimental):

  • macOS 14.4 (Sonoma) or later
  • Python 3.10+
  • Swift CLI helper binary (proctap-macos)
  • Audio capture permission
  • โš ๏ธ EXPERIMENTAL: Core Audio Process Tap API support implemented
  • โš ๏ธ REQUIREMENT: Requires macOS 14.4+ for Process Tap API

๐Ÿงฐ Basic Usage (Callback API)

from proctap import ProcTap, StreamConfig

def on_chunk(pcm: bytes, frames: int):
    print(f"Received {len(pcm)} bytes ({frames} frames)")

pid = 12345  # Target process ID

tap = ProcTap(pid, StreamConfig(), on_data=on_chunk)
tap.start()

input("Recording... Press Enter to stop.\n")

tap.close()

๐Ÿ” Async Usage (Async Generator)

import asyncio
from proctap import ProcTap

async def main():
    tap = ProcTap(pid=12345)
    tap.start()

    async for chunk in tap.iter_chunks():
        print(f"PCM chunk size: {len(chunk)} bytes")

asyncio.run(main())

๐Ÿ“„ API Overview

class ProcTap

Control Methods:

Method Description
start() Start WASAPI per-process capture
stop() Stop capture
close() Release native resources

Data Access:

Method Description
iter_chunks() Async generator yielding PCM chunks
read(timeout=1.0) Synchronous: read one chunk (blocking)

Properties:

Property Type Description
is_running bool Check if capture is active
pid int Get target process ID
config StreamConfig Get stream configuration

Utility Methods:

Method Description
set_callback(callback) Change or remove audio callback
get_format() Get audio format info (dict)

Audio Format

Native Backend Format (Windows WASAPI, hardcoded in C++):

Parameter Value Description
Sample Rate 44,100 Hz CD quality (fixed in C++)
Channels 2 Stereo (fixed in C++)
Bit Depth 16-bit PCM format (fixed in C++)

Output Format Conversion (v0.2.1+):

The StreamConfig class controls the output format through automatic conversion:

  • Native format โ†’ converted to match your StreamConfig settings
  • Supports sample rate conversion (e.g., 44.1kHz โ†’ 48kHz)
  • Supports channel conversion (mono โ†” stereo)
  • Supports bit depth conversion (8/16/24/32-bit)
  • Zero overhead when formats match (automatic bypass)

Example:

# Get audio as 48kHz mono 24-bit
config = StreamConfig(sample_rate=48000, channels=1, width=3)
tap = ProcTap(pid, config=config)

๐ŸŽฏ Use Cases

  • ๐ŸŽฎ Record audio from one game only
  • ๐Ÿ•ถ Capture VRChat audio cleanly (without system sounds)
  • ๐ŸŽ™ Feed high-SNR audio into AI recognition models
  • ๐Ÿ“น Alternative to OBS "Application Audio Capture"
  • ๐ŸŽง Capture DAW/app playback for analysis tools

๐Ÿ“š Example: Save to WAV

from proctap import ProcTap
import wave

pid = 12345

wav = wave.open("output.wav", "wb")
wav.setnchannels(2)
wav.setsampwidth(2)  # 16-bit PCM
wav.setframerate(44100)  # Native format is 44.1 kHz

def on_data(pcm, frames):
    wav.writeframes(pcm)

with ProcTap(pid, on_data=on_data):
    input("Recording... Press Enter to stop.\n")

wav.close()

๐Ÿ“š Example: Synchronous Read API

from proctap import ProcTap

tap = ProcTap(pid=12345)
tap.start()

try:
    while True:
        chunk = tap.read(timeout=1.0)  # Blocking read
        if chunk:
            print(f"Got {len(chunk)} bytes")
            # Process audio data...
        else:
            print("Timeout, no data")
except KeyboardInterrupt:
    pass
finally:
    tap.close()

๐Ÿง Linux Example

from proctap import ProcessAudioCapture, StreamConfig
import wave

pid = 12345  # Your target process ID

# Create WAV file
wav = wave.open("linux_capture.wav", "wb")
wav.setnchannels(2)
wav.setsampwidth(2)
wav.setframerate(44100)

def on_data(pcm, frames):
    wav.writeframes(pcm)

# Create stream config (Linux backend respects these settings)
config = StreamConfig(sample_rate=44100, channels=2)

try:
    with ProcessAudioCapture(pid, config=config, on_data=on_data):
        print("โš ๏ธ  Make sure the process is actively playing audio!")
        input("Recording... Press Enter to stop.\n")
finally:
    wav.close()

Linux-specific requirements:

  • Install system package: sudo apt-get install pulseaudio-utils (provides parec command)
  • Python dependency pulsectl is automatically installed with pip install proc-tap
  • The target process must be actively playing audio
  • See examples/linux_basic.py for a complete example

๐ŸŽ macOS Example

from proctap import ProcessAudioCapture, StreamConfig
import wave

pid = 12345  # Your target process ID

# Create WAV file
wav = wave.open("macos_capture.wav", "wb")
wav.setnchannels(2)
wav.setsampwidth(2)
wav.setframerate(48000)  # macOS backend default is 48 kHz

def on_data(pcm, frames):
    wav.writeframes(pcm)

# Create stream config (macOS backend respects these settings)
config = StreamConfig(sample_rate=48000, channels=2)

try:
    with ProcessAudioCapture(pid, config=config, on_data=on_data):
        print("โš ๏ธ  Make sure the process is actively playing audio!")
        print("โš ๏ธ  On first run, macOS will prompt for permission.")
        input("Recording... Press Enter to stop.\n")
finally:
    wav.close()

macOS-specific requirements:

  • macOS 14.4 (Sonoma) or later
  • Swift CLI helper binary (proctap-macos) - automatically built during installation if Swift toolchain available
  • Audio capture permission - macOS will prompt on first run
  • The target process must be actively playing audio
  • See examples/macos_basic.py for a complete example

Building the Swift helper manually:

cd swift/proctap-macos
swift build -c release
cp .build/release/proctap-macos ../../src/proctap/bin/

๐Ÿ— Build From Source

git clone https://github.com/m96-chan/ProcTap
cd ProcTap
pip install -e .

Windows Build Requirements:

  • Visual Studio Build Tools
  • Windows SDK
  • CMake (if you modularize the C++ code)

Linux:

  • No C++ compiler required (pure Python)
  • System dependencies: pulseaudio-utils or pipewire with libpipewire-0.3-dev

macOS:

  • No C++ compiler required (pure Python)
  • Swift toolchain (optional, for building the Swift CLI helper)
  • If Swift is not available, pre-built binary is included in the package

๐Ÿค Contributing

Contributions are welcome! We have structured issue templates to help guide your contributions:

Special Interest:

  • PRs from WASAPI/C++ experts are especially appreciated
  • Linux backend improvements (PulseAudio/PipeWire per-app isolation)
  • macOS backend testing (Core Audio Process Tap on macOS 14.4+)
  • Cross-platform testing and compatibility
  • Performance profiling and optimization

๐Ÿ“„ License

MIT License

๐Ÿ‘ค Author

m96-chan
Windows Audio / VRChat Tools / Python / C++
https://github.com/m96-chan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proc_tap-0.3.0.tar.gz (61.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

proc_tap-0.3.0-py3-none-any.whl (58.9 kB view details)

Uploaded Python 3

proc_tap-0.3.0-cp313-cp313-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.13Windows x86-64

proc_tap-0.3.0-cp312-cp312-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.12Windows x86-64

proc_tap-0.3.0-cp311-cp311-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.11Windows x86-64

proc_tap-0.3.0-cp310-cp310-win_amd64.whl (78.2 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file proc_tap-0.3.0.tar.gz.

File metadata

  • Download URL: proc_tap-0.3.0.tar.gz
  • Upload date:
  • Size: 61.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0.tar.gz
Algorithm Hash digest
SHA256 002c5ef666eae000641cb5cbd66802cbcace8a79845f8781d468b5e0295d3746
MD5 5e46570eb9e03b29bdd2be462156804d
BLAKE2b-256 46165401678eae7a91c48bfe050d2e891c0e2d189d1d6ee923bf886683746f20

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0.tar.gz:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proc_tap-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: proc_tap-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 58.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f30b038a3ae5090a7b0a20a4e215bdcb845995fc16b346e2c07d82770cd950a5
MD5 a6916bb9a58588044fe8cef506201948
BLAKE2b-256 7a28d9ba76b13049effffc7fba1a4912869fa2d06756dda74a50d83b19ec77c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0-py3-none-any.whl:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proc_tap-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: proc_tap-0.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bf77f7dae4fab1dfbadaa6898480cb9d4e203ef84c83c0c2d895539bba3c14be
MD5 57e74eb6495058dd1a382d2f744201a5
BLAKE2b-256 e3b81d654838bb64b46b1ca5c96f04a44e0def13f936ba60ee3ad8cb5c71fa5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0-cp313-cp313-win_amd64.whl:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proc_tap-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: proc_tap-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 65a26e29fb629fc1110c7615ee43961d833b103be9d582fd76ce1b1e1e177127
MD5 890c083f8d5c5c50fd374ec1fd0ad375
BLAKE2b-256 85b3cdfdd89b5959a620bdabb0fee8ce534446b1dcd20440e55fd3a8bb0cb80a

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0-cp312-cp312-win_amd64.whl:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proc_tap-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: proc_tap-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dacc66418207ef681cef737842a7a3612b21db898055eb3b20c935d5800115a7
MD5 c67fbb584fa12b26240daed34a6d96b7
BLAKE2b-256 f5f9a750d4a943c01a481ddeccf1e28e676633721f6d72d6af436c4b61a9a761

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0-cp311-cp311-win_amd64.whl:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proc_tap-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: proc_tap-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 78.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for proc_tap-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2e9abe606ddaed623c0fb11f014a9401af9c487fa75028d0874cfb1b4f3817fd
MD5 ac8cd5299593ac87041564a51efbc03c
BLAKE2b-256 0261bfa41d04fb18d3b2d9c9e7a944e9199bc6eff6b3b37c5197884ba31cd231

See more details on using hashes here.

Provenance

The following attestation bundles were made for proc_tap-0.3.0-cp310-cp310-win_amd64.whl:

Publisher: publish-pypi.yml on m96-chan/ProcTap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page