Simple, dependency-light continuous recording library for UltraMic USB microphones — install with pip, works anywhere.
Project description
ultramic
Simple, dependency-light continuous recording library for Dodotronic Ultramic384k_evo USB microphone; install with pip, works anywhere.
Built on sounddevice (PortAudio), so it runs the same way on Linux, macOS, and Windows — no platform-specific audio backend required.
Features
- Automatic device detection by name (no hardcoded device indices)
- Waits for USB enumeration with a configurable timeout
- Verifies the device supports the target sample rate before recording
- Continuous recording with automatic file rotation (new
.wavevery N seconds) - Simple CLI entry point, plus a Python API for use in your own scripts
- Zero required dependencies beyond
sounddevice,soundfile, andnumpy
Installation
pip install ultramic
For local development:
git clone git@github.com:jgers32/ultramic.git
cd ultramic
uv venv
source .venv/bin/activate
uv pip install -e ".[dev,viz]"
Quickstart (CLI)
ultramic-record --audio-dir ./audio --file-duration 600
This will:
- Wait for a device with "UltraMic" in its name to enumerate (default timeout: 30s)
- Verify it supports 384kHz recording
- Record continuously, rotating to a new timestamped
.wavfile every 600 seconds - Log status and errors to
./errors/
Run ultramic-record --help for all options.
Quickstart (Python API)
from pathlib import Path
from ultramic import wait_for_device, verify_sample_rate, record_continuous
device = wait_for_device(timeout=30)
if not verify_sample_rate(device, sample_rate=384000):
raise RuntimeError("Device doesn't support 384kHz")
record_continuous(device, output_dir=Path("./audio"), file_duration_sec=600)
See examples/ for more:
examples/list_devices.py— list all available input devices and their namesexamples/basic_record.py— minimal find-device-and-record exampleexamples/timed_recording.py— record for a fixed total duration and stop automatically
Visualizing a recording
Generate a waveform, spectrogram, log-scale spectrogram, and mel spectrogram for a recorded file:
python scripts/visualize.py path/to/recording.wav
Saves a combined figure to ./plots/<filename>.png (use --plots-dir to change the output location).
Testing
pytest # unit tests only — no hardware required, safe for CI
pytest -m hardware # hardware-dependent tests — requires a real UltraMic attached
pytest -v # verbose output
tests/test_device.py and tests/test_recorder.py mock the audio backend and test pure logic (device matching, timeout handling, sample-rate checks) — these run anywhere, with no hardware needed.
tests/test_hardware.py exercises the real device: finding it, verifying its sample rate, and recording actual audio. These are marker-gated and skipped by default since they require physical hardware.
Platform notes
- WSL: the UltraMic must be passed through to WSL with
usbipd bind/usbipd attachbefore it will be visible toultramic. Without this step,wait_for_devicewill time out as if no device were connected. - Sample rate: UltraMic devices default to 384kHz, well above what most audio tooling assumes (16–48kHz). If you extend the visualization or add feature extraction, double-check that any library defaults (FFT window size, mel filter count, etc.) are adjusted for this — see
scripts/visualize.pyfor an example of tuningn_fftandfmaxfor high sample rates.
License
MIT — see LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ultramic-0.1.1.tar.gz.
File metadata
- Download URL: ultramic-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc837a1df0ad128cf4f231908af336969e92d6886d375b6777ad7410fbbd8d29
|
|
| MD5 |
8915f806691d71237f309865bb866402
|
|
| BLAKE2b-256 |
c9eea5f4b3225bd3900d9a7b76bb6cafc1853f3e18b35fe5af918c62b07fe1a5
|
File details
Details for the file ultramic-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ultramic-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f09353947a0d7327316234b1d7fecbc756dbe0dd5064e1f4ca778c4909b5e1e8
|
|
| MD5 |
89ed6c11ef0107ebb6847152b8c6aedf
|
|
| BLAKE2b-256 |
2c92e37094f33aef3b8dfec2001a05585c00abc0a3d958e5ff04a8bea1d98310
|