# Audio Glitch Detector
[](https://badge.fury.io/py/audio-glitch-detector)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/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
```bash
pip install audio-glitch-detector
```
### From source with uv (development)
```bash
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:
```bash
audio-glitch-detector -f path/to/audio.wav
```
Monitor live audio stream:
```bash
audio-glitch-detector
```
Save glitch blocks for analysis:
```bash
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:

## Test Files
Validate the detector with test files with a known number of discontinuities:
```bash
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
```bash
uv sync --dev
```
### Run the application
```bash
uv run audio-glitch-detector --help
```
### Run tests
```bash
uv run pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "audio-glitch-detector",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "audio, cli, detection, glitch, signal-processing",
"author": null,
"author_email": "Kasper Nyhus <kanyhus@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/14/ea/a5ecb60596daa57617f1bc4a48d0cbe0023ee66bfccefbf46c15ffd8c730/audio_glitch_detector-0.2.1.tar.gz",
"platform": null,
"description": "# Audio Glitch Detector\n\n[](https://badge.fury.io/py/audio-glitch-detector)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\nDetect audio glitches and discontinuities in sinusoidal audio signals by analyzing the signal derivative.\n\n**Important:** This tool is will only work with sinusoidal audio signals.\n\n### Limitations\nThe algorithm detects discontinuities, so glitches that does not directly produce discontinuities might not be picked up.\nIt can detect single sample errors in a sine wave. The test files in `test_files/` show cases where the algorithm works well.\n\n## Installation\n\n### From PyPI\n```bash\npip install audio-glitch-detector\n```\n\n### From source with uv (development)\n```bash\ngit clone https://github.com/kaspernyhus/audio-glitch-detector\ncd audio-glitch-detector\nuv sync --dev\n```\n\n## Quick Start\n\n### Command Line Usage\n\nAnalyze a WAV file with automatic threshold:\n```bash\naudio-glitch-detector -f path/to/audio.wav\n```\n\nMonitor live audio stream:\n```bash\naudio-glitch-detector\n```\n\nSave glitch blocks for analysis:\n```bash\naudio-glitch-detector -f audio.wav --save-blocks\n```\n\n### Library Usage\n\nsee `examples/` for usage examples.\n\n\n## Visual Analysis\n\nWhen using `--save-blocks`, glitch blocks (max 50) are saved as .wav files and with waveform visualizations showing the derivative analysis:\n\n\n\n## Test Files\n\nValidate the detector with test files with a known number of discontinuities:\n```bash\naudio-glitch-detector -f test_files/sine_discont_2_mono.wav\n```\n\nExpected output:\n```\nNumber of discontinuities detected: 2\n0:00:01.892857\n0:00:03.288367\n```\n\n\n## How It Works\n\n1. **Derivative Analysis**: Calculates the first derivative of audio samples\n2. **Threshold Detection**: Uses 99.5th percentile of derivative distribution\n3. **Peak Identification**: Finds samples exceeding the threshold\n\n\n## Development\n\n### Setup\n```bash\nuv sync --dev\n```\n\n### Run the application\n```bash\nuv run audio-glitch-detector --help\n```\n\n### Run tests\n```bash\nuv run pytest\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Detect audio glitches and discontinuities in sinusoidal audio signals",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/kaspernyhus/audio-glitch-detector",
"Issues": "https://github.com/kaspernyhus/audio-glitch-detector/issues",
"Repository": "https://github.com/kaspernyhus/audio-glitch-detector"
},
"split_keywords": [
"audio",
" cli",
" detection",
" glitch",
" signal-processing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "54a9137690d07057a5e5adb1628e18a46101cde239ce20acf8a0f6d5423766c9",
"md5": "0641719f3dbde187da43e5a239e66440",
"sha256": "d1675f1c49e72233e9b645e45307e5eeb2b5dc7e7396af71ee3d4405b92399f5"
},
"downloads": -1,
"filename": "audio_glitch_detector-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0641719f3dbde187da43e5a239e66440",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 20269,
"upload_time": "2025-08-21T21:50:02",
"upload_time_iso_8601": "2025-08-21T21:50:02.969975Z",
"url": "https://files.pythonhosted.org/packages/54/a9/137690d07057a5e5adb1628e18a46101cde239ce20acf8a0f6d5423766c9/audio_glitch_detector-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "14eaa5ecb60596daa57617f1bc4a48d0cbe0023ee66bfccefbf46c15ffd8c730",
"md5": "5b4aaf8a0d8f938673808513e05465a1",
"sha256": "5e0cf581543392401bf9e4d6ec79b8c51907d12a14766a69e1f3a253c30601d1"
},
"downloads": -1,
"filename": "audio_glitch_detector-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "5b4aaf8a0d8f938673808513e05465a1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 10552279,
"upload_time": "2025-08-21T21:50:14",
"upload_time_iso_8601": "2025-08-21T21:50:14.866824Z",
"url": "https://files.pythonhosted.org/packages/14/ea/a5ecb60596daa57617f1bc4a48d0cbe0023ee66bfccefbf46c15ffd8c730/audio_glitch_detector-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-21 21:50:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kaspernyhus",
"github_project": "audio-glitch-detector",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "audio-glitch-detector"
}