Skip to main content

pcmtap

Record what an app, or the whole Mac, is playing, as PCM audio. It uses Core Audio process taps (macOS 14.2+), so there is no BlackHole, no virtual device and no change to your audio routing.

from pcmtap import record

record("spotify.wav", 30, app="Spotify", mute=True)   # 30 s of Spotify alone, silent on the speakers
record("everything.flac", 10)                          # whatever the Mac plays
pip install pcmtap
pcmtap check                                           # what is missing, with the fix
pcmtap record out.wav --seconds 30 --app Spotify --mute
pcmtap list --playing                                  # which processes are making sound

The first run

The first run needs two things from macOS.

  1. The helper is built. The real-time capture is a small Swift program shipped as source. On first use pcmtap compiles it with swiftc (from the Xcode command line tools: xcode-select --install) into ~/.local/share/pcmtap/bin/.
  2. The permission is granted. macOS asks once whether pcmtap-helper may record system audio: pcmtap permission --request shows the dialog. You can also allow it later in System Settings > Privacy & Security > Screen & System Audio Recording. Without the permission, macOS hands a tap silence rather than an error; pcmtap notices and raises PermissionMissing.

The helper makes itself responsible for its own privacy permissions. So the grant is remembered for pcmtap-helper, whichever terminal, IDE or detached tmux session runs it. A new pcmtap version with a changed helper asks once more.

Choosing what to record

  • app="Spotify" or app="com.spotify.client": an app by name or bundle id. A bundle id is a prefix, so an app's helper processes are included.
  • pid=1234: one process. Lists work for both.
  • Neither: the whole Mac. exclude=True records everything except the selection.
  • mute=True keeps the recorded processes off the speakers while they are recorded; the recording itself stays at full level.

An app can be tapped once it has opened an audio stream (played something since it launched).

Streaming

Tap is a context manager that yields chunks of interleaved float32 frames. The functions in pcmtap.stream compose over them:

from pcmtap import Tap, skip_silence, take_seconds, write_audio

with Tap(app="Spotify", mute=True) as tap:
    fmt = tap.format                                    # AudioFormat(sample_rate=44100, channels=2)
    chunks = skip_silence(iter(tap), fmt, timeout_s=20)
    write_audio("song.flac", take_seconds(chunks, fmt, 180), fmt)

.wav is written natively (32-bit float, the exact samples). Other formats go through ffmpeg.

Agents

The package ships an agent skill (pcmtap/data/skills/pcmtap/SKILL.md): gh skill install thorwhalen/pcmtap pcmtap. CLAUDE.md is the map for agents developing pcmtap.

Metadata

Release files for pcmtap 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcmtap 0.0.2
File Size Uploaded Provenance Actions
pcmtap-0.0.2.tar.gz 20.2 kB Without provenance Details for pcmtap-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pcmtap 0.0.2
File Interpreter ABI Platform Actions
pcmtap-0.0.2-py3-none-any.whl Python 3 none any Details for pcmtap-0.0.2-py3-none-any.whl

Total release size: 43.0 kB

Release files / pcmtap-0.0.2.tar.gz

Download URL pcmtap-0.0.2.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bd26b9abb14b7fdc208fae31cf5ef2f7c403681151fa09de02c49999255a5c3f
BLAKE2b-256 checksum
How to use checksums
8a621f2eda32fe8c488bb9b724bd5a888ff4e641f79f8f5ee52f9bd40215a23c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pcmtap-0.0.2-py3-none-any.whl

Download URL pcmtap-0.0.2-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dafbe2dd1ffe38d04d940e6f20e85d78d553406be48e413d958621998ebd988f
BLAKE2b-256 checksum
How to use checksums
3642581f5e852575f7addc939a3fb09723a0a67aafbc3cf1f8810dc373b5c351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pcmtap 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page