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.3

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.3
File Size Uploaded Provenance Actions
pcmtap-0.0.3.tar.gz 20.7 kB Without provenance Details for pcmtap-0.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 43.7 kB

Release files / pcmtap-0.0.3.tar.gz

Download URL pcmtap-0.0.3.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c4caa73dcf74b77aeef10642b4a2d8e8570c8fdc16d88d72382582ff4c67d284
BLAKE2b-256 checksum
How to use checksums
aa27370784e025c820a66a554798d905dd28eaf1a790476b5850e3f3a7f0c105
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.3-py3-none-any.whl

Download URL pcmtap-0.0.3-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95fd38cbbf9eca176aeba068f190a066dd92d8e061d76412770d91049e120c09
BLAKE2b-256 checksum
How to use checksums
4bf85085de8c628aed1ef1b21a7519fd44680e9c02ec3fd735adb81e76cc99f7
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.3

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.3 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