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.

Prerequisites

  • Python >= 3.9
  • FFTW3 development headers
    • Ubuntu/Debian: sudo apt install libfftw3-dev
    • macOS: brew install fftw
  • A C compiler (gcc or clang)

Installation

# Clone the miniDSP C library (if not already present)
git clone https://github.com/wooters/miniDSP.git

# Create virtual environment (uses .python-version for Python version)
uv venv

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

Or for development:

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
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

Signal Analysis

Function Description
rms(signal) Root mean square
energy(signal) Signal energy
power(signal) / power_db(signal) Signal power (linear / dB)
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

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
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

Delay Estimation (GCC-PHAT)

Function Description
get_delay(sig_a, sig_b, margin, weighting) Delay between two 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

Spectrogram Art

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

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.2.0.tar.gz (175.0 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.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (819.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyminidsp-0.2.0-cp313-cp313-macosx_15_0_arm64.whl (425.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyminidsp-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (819.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyminidsp-0.2.0-cp312-cp312-macosx_15_0_arm64.whl (425.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyminidsp-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (817.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyminidsp-0.2.0-cp311-cp311-macosx_15_0_arm64.whl (425.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyminidsp-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (817.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyminidsp-0.2.0-cp310-cp310-macosx_15_0_arm64.whl (425.5 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

pyminidsp-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (817.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyminidsp-0.2.0-cp39-cp39-macosx_15_0_arm64.whl (425.5 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyminidsp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 255a7ab75283fb2595accc3111473799566856cd2c27da9582d61c1262877d52
MD5 dc3f88153e051be181612de35c4b9c0d
BLAKE2b-256 aefe8e9b2dd14394035463b908791b0bd43a799f3d7c53a9ce5fe66ef081f9b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8666a58abd8bc485f853a0c4a060a51cd109e25519132c74ff521a16f50c955
MD5 b5a3fd440958eb8f8b97b355fdaaeae4
BLAKE2b-256 318a591e3674cd6b186ca9e64e6826bfd535d08cd9dce8444e14a9b6787fdc56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 989bc75ba9da66bb0cd9a7987d30bcfba479fcb799c0605be800de100ceb4352
MD5 84718a38c9045c9b354701b9c19675ea
BLAKE2b-256 4edd12421aa853556e9884b2510ef80c21cb714e34ff00064e97682cdb88f03a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5ee0426bd84245093afe7ad8a56caf7af7e672f7d340f46669c41ddc7e747aa
MD5 910f55ad8c8ea9c12f23ca499804b42e
BLAKE2b-256 53a5b4ebe1a262ed6e3e50f1b947f1f05c76a00b63e7bff89d651052516bcd16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c9650b795fa0e0472c64daa5cb4ade76903673f7f35a28bcbf3295a05d45dc4c
MD5 0441e787fde576fdf836f81db7d57920
BLAKE2b-256 8139b9d95f1c2dfe1a9c6111696f1e6f8c598d5a6b247ee60605089b29490d9b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd78d99d63594095b15759067412fac21d1189dadb7750b62d2e15a0799e3be3
MD5 a72947e37121346ad4273c1d71539e3f
BLAKE2b-256 442b4e402212bf98dc793e169bb9d10321425e3918251699bebcede51952df95

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 17fd5167e5b72fad98437ea43eb7d854f5bbd88699874ee7d4d2f8bc114a2807
MD5 05bf93e65b2c2cab2c599ebcab5787f0
BLAKE2b-256 e3f583b718be8e7e4ca0e334eb74f5fd5dc86a05699c2c8efc4b438b710a43ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d09a0a0593015058aa28edbeb035eabfa21378feaeb066216ccb6677dd05e77
MD5 670fa76973fa246fc7d10afa099fd5f8
BLAKE2b-256 4b3db6c875142cc486cd078f03440431b68e4cd4df9afea2d5f29c0ee3ff7e19

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6790a3624c26168c8cd6e295b5f848f894e0d973eaec21da9420bf0d78aaffc6
MD5 f4fda5e978a7d04ada1e0fb8c54633fd
BLAKE2b-256 2227d8142ae44a1c307ce1e7b96a48ba29ab24f91b58dff4905c34d7b37dc479

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eace2c29da55c2741f3f9e7c5260ec03d558f22016c5dd1e738363637d06d968
MD5 4fcd702158284d23efb00b87630a4ada
BLAKE2b-256 dd105e6ef7a0551f2133d2552cce1f6925d9f754d9faa06d5c8c0bccc2064921

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyminidsp-0.2.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a61f40d29489e2b231e0e968c0ec7447a728333180d17fe1c27e62a62f6e4bcf
MD5 f77978652361f706fb84878ccb912d61
BLAKE2b-256 be3563559db598aee7f57fc9585af0f169d166ff610fd3ddfa238f30ed192911

See more details on using hashes here.

Provenance

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