Skip to main content

Python bindings to the miniDSP C library

Project description

pyminidsp

PyPI version Python versions License Build wheels Docs

AI agents: fetch llms-full.txt for the complete API reference and tutorials in a single markdown file.

Documentation

Python bindings to the miniDSP C library.

A comprehensive DSP toolkit providing signal generation, spectral analysis, filtering, effects, and more. All functions accept and return NumPy arrays.

Installation

Pre-built wheels are available for Linux x86-64 and macOS ARM64 (Apple Silicon), with Python 3.9–3.13. Wheels include the compiled C extension (no compiler needed), but FFTW3 must be installed on your system (apt install libfftw3-3 or brew install fftw).

pip install pyminidsp

Building from Source

If you need to build from source (e.g. unsupported platform or development):

Prerequisites:

  • FFTW3 development headers
    • Ubuntu/Debian: sudo apt install libfftw3-dev
    • macOS: brew install fftw
  • A C compiler (gcc or clang)
# Clone the miniDSP C library
git clone https://github.com/wooters/miniDSP.git

# Create virtual environment
uv venv

# Install pyminidsp (set MINIDSP_SRC to point to the C library)
MINIDSP_SRC=./miniDSP uv sync

For development (includes test dependencies):

MINIDSP_SRC=./miniDSP uv sync --extra dev

Quick Start

import pyminidsp as md

# Generate a 440 Hz sine wave (1 second at 44.1 kHz)
signal = md.sine_wave(44100, amplitude=1.0, freq=440.0, sample_rate=44100.0)

# Compute the magnitude spectrum
mag = md.magnitude_spectrum(signal)

# Compute MFCCs from a frame
coeffs = md.mfcc(signal[:512], sample_rate=44100.0, num_mels=26, num_coeffs=13)

# Apply a low-pass biquad filter
lpf = md.BiquadFilter(md.LPF, freq=1000.0, sample_rate=44100.0)
filtered = lpf.process_array(signal)

# Clean up FFT caches when done
md.shutdown()

API Overview

Signal Generators

Function Description
sine_wave(n, amplitude, freq, sample_rate) Pure sine tone
white_noise(n, amplitude, seed) Gaussian white noise
impulse(n, amplitude, position) Kronecker delta
chirp_linear(n, amplitude, f_start, f_end, sample_rate) Linear frequency sweep
chirp_log(n, amplitude, f_start, f_end, sample_rate) Logarithmic frequency sweep
square_wave(n, amplitude, freq, sample_rate) Square wave
sawtooth_wave(n, amplitude, freq, sample_rate) Sawtooth wave
shepard_tone(n, amplitude, base_freq, sample_rate, rate, num_octaves) Shepard tone illusion

Spectral Analysis

Function Description
magnitude_spectrum(signal) One-sided magnitude spectrum via FFT
power_spectral_density(signal) Periodogram PSD estimate
phase_spectrum(signal) Phase spectrum in radians
stft(signal, n, hop) Short-Time Fourier Transform
stft_num_frames(signal_len, n, hop) Number of STFT frames
mel_filterbank(n, sample_rate, num_mels) Mel-spaced triangular filterbank
mel_energies(signal, sample_rate, num_mels) Mel-band energies
mfcc(signal, sample_rate, num_mels, num_coeffs) Mel-frequency cepstral coefficients

Window Functions

Function Description
hann_window(n) Hann window
hamming_window(n) Hamming window
blackman_window(n) Blackman window
rect_window(n) Rectangular window
kaiser_window(n, beta) Kaiser window (configurable shape)

Math Utilities

Function Description
bessel_i0(x) Zeroth-order modified Bessel function I₀
sinc(x) Normalized sinc function

Signal Measurement

Function Description
dot(a, b) Dot product of two vectors
entropy(signal) Normalised entropy of a distribution
energy(signal) Signal energy
power(signal) / power_db(signal) Signal power (linear / dB)
rms(signal) Root mean square

Signal Analysis

Function Description
zero_crossing_rate(signal) Zero-crossing rate
autocorrelation(signal, max_lag) Normalised autocorrelation
peak_detect(signal, threshold, min_distance) Local maxima detection
f0_autocorrelation(signal, sample_rate, min_freq, max_freq) F0 via autocorrelation
f0_fft(signal, sample_rate, min_freq, max_freq) F0 via FFT peak picking
mix(signal_a, signal_b, weight_a, weight_b) Weighted sum of two signals

Signal Scaling

Function Description
scale(value, old_min, old_max, new_min, new_max) Map a value from one range to another
scale_vec(signal, old_min, old_max, new_min, new_max) Map vector elements between ranges
fit_within_range(signal, new_min, new_max) Fit signal values within a range
adjust_dblevel(signal, target_db) Automatic gain control

Effects & Filters

Function Description
delay_echo(signal, delay_samples, feedback, dry, wet) Echo effect
tremolo(signal, rate_hz, depth, sample_rate) Amplitude modulation
comb_reverb(signal, delay_samples, feedback, dry, wet) Comb-filter reverb
convolution_time(signal, kernel) Time-domain convolution
convolution_fft_ola(signal, kernel) FFT overlap-add convolution
convolution_num_samples(signal_len, kernel_len) Output length of linear convolution
moving_average(signal, window_len) Moving average filter
fir_filter(signal, coeffs) FIR filter
design_lowpass_fir(num_taps, cutoff, sr, beta) Design Kaiser-windowed lowpass FIR
lowpass_brickwall(signal, cutoff_hz, sr) FFT-based ideal lowpass filter
BiquadFilter(type, freq, sample_rate) IIR biquad filter (LPF/HPF/BPF/etc.)

Resampling

Function Description
resample(signal, in_rate, out_rate) Polyphase sinc resampler
resample_output_len(input_len, in_rate, out_rate) Compute resampled output length

DTMF

Function Description
dtmf_generate(digits, sample_rate, tone_ms, pause_ms) Generate DTMF tones
dtmf_detect(signal, sample_rate) Detect DTMF digits
dtmf_signal_length(num_digits, sample_rate, tone_ms, pause_ms) Calculate samples needed for DTMF

Delay Estimation (GCC-PHAT)

Function Description
get_delay(sig_a, sig_b, margin, weighting) Delay between two signals
get_multiple_delays(signals, margin, weighting) Delays from reference to M-1 signals
gcc(sig_a, sig_b, weighting) Full cross-correlation

Audio Steganography

Function Description
steg_encode(host, message, sample_rate, method) Hide text in audio
steg_decode(stego, sample_rate, method) Recover hidden text
steg_encode_bytes(host, data, sample_rate, method) Hide binary data
steg_decode_bytes(stego, sample_rate, method) Recover binary data
steg_detect(signal, sample_rate) Detect steganography method
steg_capacity(host, sample_rate, method) Maximum message length

Spectrogram Art

Function Description
spectrogram_text(text, freq_lo, freq_hi, duration, sample_rate) Text visible in spectrogram

Constants

Constant Description
LPF, HPF, BPF, NOTCH, PEQ, LSH, HSH Biquad filter types
STEG_LSB, STEG_FREQ_BAND, STEG_SPECTEXT Steganography methods
STEG_TYPE_TEXT, STEG_TYPE_BINARY Steganography payload types
GCC_SIMP, GCC_PHAT GCC weighting modes

Running Tests

MINIDSP_SRC=./miniDSP uv run pytest tests/ -v

License

MIT

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

pyminidsp-0.6.1.tar.gz (222.4 kB view details)

Uploaded Source

Built Distributions

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

pyminidsp-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (879.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.1-cp313-cp313-macosx_15_0_arm64.whl (446.9 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyminidsp-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (880.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.1-cp312-cp312-macosx_15_0_arm64.whl (446.9 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyminidsp-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.1-cp311-cp311-macosx_15_0_arm64.whl (446.8 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyminidsp-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.1-cp310-cp310-macosx_15_0_arm64.whl (446.8 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

pyminidsp-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.1-cp39-cp39-macosx_15_0_arm64.whl (446.8 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file pyminidsp-0.6.1.tar.gz.

File metadata

  • Download URL: pyminidsp-0.6.1.tar.gz
  • Upload date:
  • Size: 222.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyminidsp-0.6.1.tar.gz
Algorithm Hash digest
SHA256 42d915457be14a924a3fe24194aa37e06a4d82c3f7757924905f8f297c445d92
MD5 bdc91a6d1d3934a31de206267d30573a
BLAKE2b-256 0004594ba0f955b5a8138b022354ee1ddce605aac8c119b632f77ceb15539f0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1.tar.gz:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a85014fc687f5e2959f7957436ebe7715cc7f00e05236422c96bc90ce0cb56cd
MD5 4a8f8efb0a16c49c9fdf3638054428c5
BLAKE2b-256 61eff9da91e2eb73517639acf7c1d48173189bd53bd7bd774f779f7ff114d497

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 32538483a3350c32bf7d934e9ba771c5a6f0c0fab72f1b75788ab70ebf066c15
MD5 5c710854ba75890d8a79bd9fc8228e3c
BLAKE2b-256 a00aa21f5f37e84fad1e04f71b076e6e357b035beb3cff4f669880555ea4e1f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c1bbab6c5171c555688100c590681c96ac7c6f61b53fd8087db1a89f8ed1dda
MD5 87cad6618ee752f5a7e824fa9cff34d8
BLAKE2b-256 62dda59565f9a29362ada25432dddb31b35d0e4fc6ebf431117f84ab4e9636b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b7c4dee0fa2482afd4627c72a4ee4e792e2dc267fe60ddd4570ca384f30de204
MD5 2acad185a4a25b8101bed563f45dab1b
BLAKE2b-256 7899d1f01c5e3ec69e45697d69b8f8c373e68925063443fab7e8da1a35cc3c94

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ea471121d493a31aea460dd9892e0ca5d5439008d70051876739fe44c43659d
MD5 9db091e39b648895998bc949ea5c0e19
BLAKE2b-256 1a0716d2af39868d8892ae039b7ed3c67c36c5a63782f4c03191b5197922d58a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3d19961753560794c1106ce461dd92250343c339f5cb5e8a78aaf9909b6d7421
MD5 5437c52f319094c17731ea2aae7b8627
BLAKE2b-256 7b1a3ecc476047d9aae55c2c8feba208da0fca1c9efbbb146234ceddf757a36d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd7723ab90c1e58db111475067e979fa81ab578cec31d89b611ca3afef6046b1
MD5 c400d6ccd1fef2c08ef894bcd96273ba
BLAKE2b-256 59ee97c1039c551eea79bbdcf4bec15c909c741eca7e42efefc67c2d99c3e178

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1f8737f3c2bfc7470981df160c55a12b61edb4d9ff2822a7b978c80c8985645d
MD5 4780b225e8373fe1bae4287eda45a602
BLAKE2b-256 465d0ab32550094a3b0ccadc312076d24eb7773bda012acca4d1d083643a61e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d79d13556f145e5910a38f96986a03a10a1af4aa080d33e387e4deb8fc4f28be
MD5 8f5987ce68645f1e2809c9850f232dac
BLAKE2b-256 921693f8f505d526c0fc4b3f5c998ac2375a899905d3048a7d23f3e01490026a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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

File details

Details for the file pyminidsp-0.6.1-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.1-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 716401bc0b673e783963791abd02efad1ad8076f6046d8b76fa3c51bdb14dedd
MD5 98c38c34e357a3749016470e0e45b923
BLAKE2b-256 d387b8904b06bf7f0ad0bc636f2a5b57374896bbb3b6650a976560d2800884da

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.1-cp39-cp39-macosx_15_0_arm64.whl:

Publisher: wheels.yml on wooters/pyminidsp

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