Skip to main content

CLI toolkit for audio bench measurements — THD, THD+N, sweeps, transfer functions

Project description

ac — audio measurement CLI

Command-line toolkit for audio bench measurements.

THD, THD+N, level 'n frequency sweeps, transfer functions, live spectrum.

The ip of audio — terse, positional, unit-tagged arguments.

Alpha — only tested on Linux with JACK (native and PipeWire). sounddevice/PortAudio backend exists but is not exercised yet. macOS and Windows are untested.

Install

pip install -e .

This gives you the ac command.

Audio backend

ac auto-detects the audio backend at startup:

Backend When used Platforms
JACK (jack-client) Preferred when a JACK server is running Linux (native or PipeWire)
sounddevice (PortAudio) Fallback when JACK is unavailable Linux, macOS, Windows

To force a backend, set "backend" in ~/.config/ac/config.json:

{ "backend": "sounddevice" }

When using JACK, the server must be running before any measurement:

jackd -d alsa -d hw:0 -r 48000 -p 1024 -n 2

Quick start

ac devices                          # list available audio ports
ac setup output 11 input 0          # tell ac which channels to use
ac calibrate                        # interactive level cal (enables dBu)
ac plot 20hz 20khz 0dbu 20ppd show  # measure THD vs frequency, open plot
ac s f 20hz 20khz 0dbu              # fast output-only chirp
ac m sh                             # live spectrum, pyqtgraph window

Commands

Command What it does
devices List audio ports
setup Configure hardware — output, input, reference, range, dmm, gpio
calibrate Interface calibration
generate Play a sine or pink noise tone
sweep Level ramp or frequency chirp
plot Point-by-point THD measurement with PNG output
transfer H1 transfer function (magnitude, phase, coherence)
monitor Live spectrum with TUI bar chart
probe Auto-detect analog ports and loopback pairs (DMM + capture scan)
dmm One-off AC Vrms reading from SCPI multimeter
server Enable/disable server, show connections, connect to remote
stop Stop active generator/measurement

Units

Everything is positional. The suffix tells ac what it is:

Suffix Meaning Examples
hz khz Frequency 20hz 1khz 20000hz
dbu dbfs vrms mvrms vpp Level 0dbu -12dbfs 775mvrms 1vrms 2vpp
s Duration / interval 1s 0.5s
ppd Points per decade 10ppd 20ppd

Append show to any command to open a pyqtgraph window.

Abbreviations

Everything has a short form:

s(weep)  m(onitor)  g(enerate)  c(alibrate)  p(lot)  tf/tr(ansfer)  pr(obe)
l(evel)  f(requency)  si(ne)  pk(ink)  sh(ow)
se(tup)  d(evices)  st(op)  ref(erence)

Sessions

Group measurements into named sessions:

ac new myamp        # create + activate
ac sessions         # list all
ac use myamp        # switch
ac diff amp1 amp2   # compare

GPIO — physical button control

Optional hardware interface for hands-free operation. A usb2gpio board (Arduino Mega2560) connects via USB serial and provides physical buttons for starting/stopping tone generation, with LED feedback for active state.

Buttons trigger ZMQ commands to the server — press SINE to generate a 1 kHz tone at the calibrated level, press STOP to silence it. LEDs reflect what's playing.

ac setup gpio /dev/ttyUSB0   # enable
ac setup gpio none           # disable
ac gpio                      # show status
ac gpio log                  # stream button events

The server auto-starts the GPIO handler on launch if gpio_port is configured.

DMM — automated meter readings

Optional SCPI integration for reading a bench multimeter (e.g. Keysight 34461A) over TCP. During calibration, ac queries the DMM for AC Vrms readings instead of requiring manual entry — it connects to port 5025, sends MEAS:VOLT:AC?, and averages three readings.

The DMM value is presented as a suggestion; you can accept it or type an override.

ac setup dmm 192.168.1.100   # enable (IP or hostname of meter)
ac setup dmm disable          # disable
ac dmm                        # take a one-off reading
ac calibrate                  # uses DMM automatically if configured

Server

ac is client/server — the server manages audio I/O and runs analysis. It auto-spawns locally. For remote use:

ac server enable          # bind to all interfaces on a server
ac server 192.168.1.5     # connect to remote server

Dependencies

numpy, scipy, matplotlib, sounddevice, pyzmq. Optional: jack-client (for JACK backend), pyqtgraph (for live GUI views).

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

audiocli-0.3.0a1.tar.gz (79.8 kB view details)

Uploaded Source

Built Distribution

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

audiocli-0.3.0a1-py3-none-any.whl (89.8 kB view details)

Uploaded Python 3

File details

Details for the file audiocli-0.3.0a1.tar.gz.

File metadata

  • Download URL: audiocli-0.3.0a1.tar.gz
  • Upload date:
  • Size: 79.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for audiocli-0.3.0a1.tar.gz
Algorithm Hash digest
SHA256 069484c9a7da4993dbd443cf2009d93c015728130c2ae65d642c537808807d71
MD5 0341679ac546a91cc7213c3660e96445
BLAKE2b-256 6a1ac9ea660ed7e794f898c075e042d463f237dd468f7b909d7c113b4e7d8acb

See more details on using hashes here.

File details

Details for the file audiocli-0.3.0a1-py3-none-any.whl.

File metadata

  • Download URL: audiocli-0.3.0a1-py3-none-any.whl
  • Upload date:
  • Size: 89.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for audiocli-0.3.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 868ef7fafe15af70e2682925664eceee8d8e9a67aca31fff4f8ba7351be0434e
MD5 e42f6397d45e9d77fc30b59843610356
BLAKE2b-256 6a47ec726179ded6a0354cbb82f904696cc6e3e5e25ccde9f1c146d8c72c8984

See more details on using hashes here.

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