Skip to main content

Python bindings to the miniDSP C library

Project description

pyminidsp

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

pip install pyminidsp

Pre-built wheels are available for:

  • Linux x86-64
  • macOS ARM64 (Apple Silicon)
  • Python 3.9, 3.10, 3.11, 3.12, 3.13

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.4.0.tar.gz (200.9 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.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (839.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyminidsp-0.4.0-cp313-cp313-macosx_15_0_arm64.whl (432.3 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyminidsp-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (839.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyminidsp-0.4.0-cp312-cp312-macosx_15_0_arm64.whl (432.3 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyminidsp-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyminidsp-0.4.0-cp311-cp311-macosx_15_0_arm64.whl (432.2 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyminidsp-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyminidsp-0.4.0-cp310-cp310-macosx_15_0_arm64.whl (432.2 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

pyminidsp-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyminidsp-0.4.0-cp39-cp39-macosx_15_0_arm64.whl (432.2 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyminidsp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 481d3f6f4d49d87d107b98f776e229e067a846237af7d01e11c245b18ec2b054
MD5 6f8f3e94fa1581992e9eb616f09b2ee2
BLAKE2b-256 bd22d32ede4ffb4663c2b4c7e2e4c228313ffaf031cae7b06e66c9383a4b5cb2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b174f6f3bb01ad86a06d1130a5efd08239bbe60cb21a96d4e4a522cfcb82cd2
MD5 e04af615bba6ad8cfbbb0803d9c90f49
BLAKE2b-256 8fff551dcd474f6742099af0af6d66fa8f41d413d989382110655bbb6f92bbe5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 44cd1164c9c681c5bbfba42af027ba3b8ddd0ebf8a1ad0ccaf0fd9043a2f5eaf
MD5 3ebb3d3e45e4b14756937be0b64d40e1
BLAKE2b-256 acc60a62b0e9e29ca6a5d588177dadd3c647b4be06edd69c7493a97c22d3f71c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed8480234a120b9386298e89047374b1b92d0bcb106cf4d4e2f7702bcb43bfb4
MD5 6c88da4d4ffd03ff9ee69371318cc2a9
BLAKE2b-256 4270920920e68f69a9bd798f9ecbe1bab286a018d57df4b7b49c3cbb9142cd29

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5c825fdc52c565fec9f7537a9feaf1157ab697bfb577c8436cba3b79083c9f2d
MD5 8da60955be8dddaf73814bbef04e6215
BLAKE2b-256 2d339f785dd405427c03f4081fe5dbdf28cb62ff107977cc0e9fc0d2ccb47ab4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57c23d186456449ab3330545c2d4654105a6aaf1f8ffefb7cedc47ee6c789ef6
MD5 3cc463b61694ebc6b0fa472a2b71dffc
BLAKE2b-256 6dc2c58e3c4a3e908b82805b37def908c00ff5de86ab25fade0cee68a502ec5a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7a68b71191b08b5ec5edcc420a2f792475af997c31e57af3f8c0c9dce351c930
MD5 d59afad93b2cede942cbd8ff3f0f6b0d
BLAKE2b-256 d91a4f8ed0966d3e4429939fab56108caeebb1d731174bcc07d0686ed648541a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c5df7dc926ef01c5bf0eab71efaf0f8e9ef3638fcaa0dc7cda3943aeab8b269
MD5 5b6eef617fc9e27062f80858f3e7a0d0
BLAKE2b-256 6fe523ad2d673ae89938975f608b5521c1f9613fe9fac417f076d5a024db0362

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1bc616c415e2fdcef6177d69b9eb9eae8c9c613a8bae293844604f348977cd6b
MD5 fc8ecb38265bad938707947a5a4c11e4
BLAKE2b-256 fcb2a96f45dc649d61212847c211ab5951aa6564d0cc11bf663f7ad55c648590

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fbac416adbc1c90b476dac0adc39fa191dd1712a8d4dd3dd9baa7e7743058ddf
MD5 feb31e248cc96f6e06ebf8499093d5ef
BLAKE2b-256 f5058dbc3b076d50c7b004baaf853571de1250b98f239a3ab24c71f3f44ea8f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.4.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 28d848d23813ba59c92757149e256a37f44dd8319fdbf233df5d88e4659656d1
MD5 0c97f13e5761e65962a945203ab179b9
BLAKE2b-256 372b8547553b35e360bcc54d141321a39aaf496597ab0e0e73217209877ae6f5

See more details on using hashes here.

Provenance

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