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.0.tar.gz (220.8 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.0-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.0-cp313-cp313-macosx_15_0_arm64.whl (446.9 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyminidsp-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (880.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

pyminidsp-0.6.0-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.0-cp311-cp311-macosx_15_0_arm64.whl (446.8 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyminidsp-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

pyminidsp-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyminidsp-0.6.0-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.0.tar.gz.

File metadata

  • Download URL: pyminidsp-0.6.0.tar.gz
  • Upload date:
  • Size: 220.8 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.0.tar.gz
Algorithm Hash digest
SHA256 5148a53366eed37fb232a79c60018df4955b83d74640e2ac2f33152d0408cb72
MD5 69f15ccf2503bcc124b5399e8b77b2c0
BLAKE2b-256 1dca911187f69d93b73b3b6739e8f7d99829b3f68c25f32b2123f3d251bb60a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0.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.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3333006f9606933b1016f65528c3035d9a25bb1e5f6b347971f5cc1e1190fb6c
MD5 b9a6c3dca3ea4f97474f5f44860b2a29
BLAKE2b-256 59b45d405b4ce8917a33db33de6493663a9dffb69d7fe565bb59f7103ef2f2f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d80d81bb86644b57c83f70b573c209159a8277b1ae56859820501d5782ed09ca
MD5 b81d65572049767a30492f33411afcbd
BLAKE2b-256 eca7b8c953faa14cfd0fdefeaf42e56604a61f7326b5f75b5579e2411f636095

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a51e5096e1f4ddb8297799473c78a7971cc20dc5cdeb11fa25663ee3f5f7047
MD5 1a9b75e580320b8890a301f3a59d5492
BLAKE2b-256 e6b59477f9280b3a9af9d506fba8ab13390c2242b34d82eba735e58e45fcb8ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 77251b70c0fa5618e52c719c90fa20d40e7a2f5dc2a98886305274969335073a
MD5 599cfe71131e64c187aca75bd4552fac
BLAKE2b-256 b3cf02a6d621fec617556ffb5b9369b8ed8d99d2e599501b084012c30808c255

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3f43480915ada2cd9610d268dee405a26ca873e8ae1f6c984722f619545cfda
MD5 1921058c35f68ff588cc31e8f3841414
BLAKE2b-256 2ca153445df548604de9c61cb4428eea27a201a549209548401974e1f4642da7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3549320382469b5311dc0b341d6b8a8e3efcca2207a3923e2645b2b59f384e31
MD5 6f335d676cd9478613e1aeaf04e41e4d
BLAKE2b-256 5882de111b26b58f73af9e9b17c8ba330d289d1929afa7934cd0f0e75564659d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7e99a4da8a386783665cbb981ba746e6f34d29885761ad602662b8a57570dd5
MD5 7be1f581bd720f36ece4e23656d153d1
BLAKE2b-256 6ba95d12fffd7d172e6c7bfb889c8ce945044af53e1e0702418c1f2cf6bbb268

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d6a2c0db53f9a10345999f9e04765f9b5c64451f886dc9c9f7bb26b0a8d38a8c
MD5 587bcbeb4f125fe63702c7061e9e8b54
BLAKE2b-256 4ab6ed9061205f9324015baeaf65c5930d32d9fe6305d56717d763e62615831f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f35228f0dbea552245a72e6a633e679c4a96df9f67b22f2492b0359308538a7
MD5 ad3324e13263acc7981c24016e2df864
BLAKE2b-256 4b307d7a9ab2840a3c4152766fe4d7983a66be463a2214dc2dfadb3b531332e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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.0-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyminidsp-0.6.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 09ca4c22b45aea19f25d5ba65081142840f34292c1ed23273a5f16b68e91c8e5
MD5 f33f94fea8b8f71321bcd420673af11a
BLAKE2b-256 0849c19717e5624d2d4db861edfef6eb2d353d44ec13c9cfa3af27b5a6de528c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminidsp-0.6.0-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