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

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
BiquadFilter(type, freq, sample_rate) IIR biquad filter (LPF/HPF/BPF/etc.)

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 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.3.0.tar.gz (176.1 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.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (820.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyminidsp-0.3.0-cp313-cp313-macosx_15_0_arm64.whl (426.3 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyminidsp-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (820.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyminidsp-0.3.0-cp312-cp312-macosx_15_0_arm64.whl (426.3 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyminidsp-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (818.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyminidsp-0.3.0-cp311-cp311-macosx_15_0_arm64.whl (426.2 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyminidsp-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (818.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyminidsp-0.3.0-cp310-cp310-macosx_15_0_arm64.whl (426.2 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

pyminidsp-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (818.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyminidsp-0.3.0-cp39-cp39-macosx_15_0_arm64.whl (426.2 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyminidsp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c75debf766ace7a226700e3f48c3c0fe51338cd6585e52861233447c5e850f3b
MD5 d3ab5a35d16e4a276cdabbefa8d42d71
BLAKE2b-256 b3887e40206bc8fec4c8a3bd1c7605142e56b86aaa0072674111427d639ba895

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 df230e267cd698f598e6475250044a4a03adb26c652975992c90ad98de28ea70
MD5 587472434f2664658fb27c5306f0586b
BLAKE2b-256 14ba47bc82da01e62f29c3c8fd0c4edf05f0170a9999c37fc325e03a77466cb6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1fb6738d009598e18662ab19d748ac77e30841fd3849143e7db085cf146a4963
MD5 a5e57ea1e496599fa0f2438315ca20b4
BLAKE2b-256 c640b97f3af71155ab9b0ffa0d6849eb372d630a72c94fbda6a4f68e9739e1fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4fdb4aeffe5c67019a5c40b8214b935c16343e2b61e25f64409230502220d79
MD5 488ae7a5e84cb6ec0b0a46e7e5f15c13
BLAKE2b-256 1bcd33c3819ee205c17cacc3c265e49a5e33448e25a112b848f54d1ed3866fd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e4f2ef5961840c2c9c56e794e15b7ab41804fa97b583532a7c5f5a8dfce8ee8f
MD5 b9e9f1c861ec2a3a4c413e6f219f256f
BLAKE2b-256 5b0fc4fe6593a4637a9e6af5d4d82df7109fb2c0f138bcb57c470c49ba66f21d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e73950679e3a86cb10059484b9b6d82744729ca8236817eabb0f9388796feeb
MD5 85eee67d1bf1c4c3b58b046553dd431e
BLAKE2b-256 4d29be323da412bc888a1c213a3c188038905d6bee4e1f1f22e5a34867ca0b84

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ae9e8f6a3ffdca67f08a62ec5728d23855547f8a1875435e283dfb60864a50cf
MD5 953b4d4fa7db81edbfd72b21ade0679f
BLAKE2b-256 fef51f3f38c8311342cc7e479b7ce0085d048f7ad2b6ed7def92fc712fabaafa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c819cb7334d58fa465fcdc47831d65b5c2ebcbc78b6c7016e631a5edd2f36e74
MD5 513dbb2589035c0c58f1e1feb6d1c746
BLAKE2b-256 fefc4a7024a93f625cd6475bd0dcb46d5cb24c8cb18fe27c3b73c58dfc752cc2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d587442630bbf1b687e47e6435e936342b6d032f23674e877a6a635496103622
MD5 9b3553071e1aa7d1e26d779eee8beeb0
BLAKE2b-256 0c8790b1bf3eb73143ae26b486b41519689ae82d3c15a07e26cf27b118345032

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d4b24de57b6f9c470a871f2f350a8f29c9fae8c3c597ce7035e094a6e65dbd16
MD5 e3b694a6f645061ff5e6935815a1ee0f
BLAKE2b-256 76835b987726c4d293df29961485882fb6e5087d7f29009fcffc6c1605e09c92

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.3.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7bfc18121ccc8cb3135b80005befe376169a173c04dd6529771a74981ecd3628
MD5 8669324edafbd1a8f8dc1028d5c6bf35
BLAKE2b-256 3e618eee184eede39a2ccb6e37c9bc9afde5831db1aa747c7c6fe127390ef874

See more details on using hashes here.

Provenance

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