Skip to main content

Detect audio glitches and discontinuities in sinusoidal audio signals

Project description

Audio Glitch Detector

PyPI version Python 3.12+ License: MIT

Detect audio glitches and discontinuities in sinusoidal audio signals by analyzing the signal derivative.

Important: This tool is will only work with sinusoidal audio signals.

Limitations

The algorithm detects discontinuities, so glitches that does not directly produce discontinuities might not be picked up. It can detect single sample errors in a sine wave. The test files in test_files/ show cases where the algorithm works well.

Installation

From PyPI

pip install audio-glitch-detector

From source with uv (development)

git clone https://github.com/kaspernyhus/audio-glitch-detector
cd audio-glitch-detector
uv sync --dev

Quick Start

Command Line Usage

Analyze a WAV file with automatic threshold:

audio-glitch-detector -f path/to/audio.wav

Monitor live audio stream:

audio-glitch-detector

Save glitch blocks for analysis:

audio-glitch-detector -f audio.wav --save-blocks

Library Usage

see examples/ for usage examples.

Visual Analysis

When using --save-blocks, glitch blocks (max 50) are saved as .wav files and with waveform visualizations showing the derivative analysis:

Glitch Block Visualization

Test Files

Validate the detector with test files with a known number of discontinuities:

audio-glitch-detector -f test_files/sine_discont_2_mono.wav

Expected output:

Number of discontinuities detected: 2
0:00:01.892857
0:00:03.288367

How It Works

  1. Derivative Analysis: Calculates the first derivative of audio samples
  2. Threshold Detection: Uses 99.5th percentile of derivative distribution
  3. Peak Identification: Finds samples exceeding the threshold

Development

Setup

uv sync --dev

Run the application

uv run audio-glitch-detector --help

Run tests

uv run pytest

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

audio_glitch_detector-0.2.0.tar.gz (10.6 MB view details)

Uploaded Source

Built Distribution

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

audio_glitch_detector-0.2.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for audio_glitch_detector-0.2.0.tar.gz
Algorithm Hash digest
SHA256 69cd4512fc479d90e869500becc8f5ec8caee81581639b61e95c38748b35bbab
MD5 71a5fcf2358696b01ab1399704465ce6
BLAKE2b-256 7690053e91b1f0fdb59bde66604e8179a4329d7c4cad56ebd9dc02c770c2aadb

See more details on using hashes here.

File details

Details for the file audio_glitch_detector-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for audio_glitch_detector-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5855d60f3b2907320be17521034753219bb84c45e2d568a697883d9394119eb
MD5 6f49d611a7df916b42ecb69a7f4a177a
BLAKE2b-256 7467f9099b4227de3ba8e09b733872f27aeae764d7a18d73409e7aa42a5ab1d3

See more details on using hashes here.

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