Skip to content

academe/vinyl-scratch-removal

Repository files navigation

Vinyl Scratch Removal for Audacity

Advanced vinyl record scratch, click, and pop removal plugin using research-backed digital signal processing techniques.

Overview

This project provides a Nyquist plugin for Audacity that removes clicks, pops, and scratches from vinyl record digitizations using adaptive threshold detection and frequency-domain processing.

Key Features:

  • Native Audacity integration (no external dependencies)
  • Real-time preview capability
  • Adaptive detection adjusts to recording characteristics
  • Multi-pass processing for thorough click removal
  • Preserves musical content while removing artifacts

Also included: A Python implementation with advanced AR interpolation for highest-quality offline processing.

Documentation

📚 Comprehensive technical documentation available in docs/:

Two Implementations

1. Nyquist Plugin (Primary - Recommended for Most Users)

Algorithm: Frequency-domain separation with adaptive attenuation

  • Separates audio into low-freq (music) and high-freq (transients + clicks)
  • Adaptively attenuates detected clicks in high-frequency band
  • Recombines for natural-sounding result

Advantages:

  • Integrates directly into Audacity
  • No external dependencies or installation
  • Real-time preview
  • Fast processing
  • Easy to use

Limitations:

  • Attenuates clicks rather than fully removing (due to Nyquist language constraints)
  • Good quality but not as perfect as AR interpolation

2. Python Tool (Optional - For Highest Quality)

Algorithm: Autoregressive Linear Prediction with Cubic Spline interpolation

  • Detects clicks using second derivative analysis
  • Interpolates using AR prediction (models signal statistically)
  • Falls back to cubic spline for short clicks

Advantages:

  • Highest quality restoration (true sample interpolation)
  • State-of-the-art algorithms from research literature
  • Better for archival-quality restoration

Disadvantages:

  • Requires Python and dependencies
  • Slower processing (no real-time preview)
  • Command-line interface only

Algorithm Overview

Nyquist Plugin Algorithm

Frequency-Domain Approach (works within Nyquist's constraints):

  1. Frequency Separation: Split audio at 2kHz

    • Low-freq (<2kHz): Musical content (melody, harmony)
    • High-freq (>2kHz): Transients + clicks
  2. Adaptive Detection: Calculate local RMS envelope of high-freq component

    • Threshold adapts to varying signal levels
    • Reduces false positives from legitimate transients
  3. Attenuation: Reduce amplitude where clicks detected

    • Preserves 30% of high-freq content for natural sound
    • Smooth processing avoids discontinuities
  4. Recombination: Mix processed high-freq with unchanged low-freq

  5. Multi-pass: Repeat with decreasing threshold

    • Pass 1: Remove obvious clicks
    • Pass 2: Catch subtler artifacts

See Implementation Notes for complete technical details.

Python Tool Algorithm

Time-Domain AR Prediction (highest quality):

  1. Detection: Second derivative + adaptive threshold
  2. Interpolation: Autoregressive linear prediction
  3. Validation: Width and amplitude criteria
  4. Blending: Smooth windowing for seamless repair

See Research Findings for algorithm theory and research papers.

Installation

Nyquist Plugin (Audacity)

  1. Download the plugin:

    • Copy vinyl-scratch-removal.ny to your Audacity plugins folder:
      • Windows: C:\Program Files\Audacity\Plug-Ins\
      • macOS: ~/Library/Application Support/audacity/Plug-Ins/
      • Linux: ~/.audacity-data/Plug-Ins/ or /usr/share/audacity/plug-ins/
  2. Enable in Audacity:

    • Open Audacity
    • Go to Tools > Plugin Manager
    • Find "Vinyl Scratch Removal" and enable it
    • Click OK
  3. Use the plugin:

    • Select audio in Audacity
    • Go to Effect > Vinyl Scratch Removal
    • Adjust parameters (see Usage section)
    • Click Preview to test, then Apply

Python Tool

  1. Install Python 3.7+ (if not already installed)

  2. Install dependencies:

    pip install -r requirements.txt

    Or install individually:

    pip install numpy scipy soundfile

Usage

Nyquist Plugin

Parameters:

  • Click Sensitivity (1-100): How aggressively to detect clicks

    • 1-10: Very conservative, only obvious clicks
    • 20: Default, balanced detection
    • 50-100: Aggressive, may detect false positives
  • Maximum Click Width (ms): Maximum duration of clicks to detect

    • 0.1-2.0: Short clicks only (default: 2.0ms)
    • 2.0-5.0: Medium clicks and pops
    • 5.0-10.0: Large pops and scratches
  • Detection Mode:

    • Clicks Only: Conservative, single-pass
    • Clicks + Crackle: Standard, multi-pass (recommended)
    • Aggressive: Maximum detection, may affect audio

Recommended Settings:

  • Light cleaning: Sensitivity=10, Width=2.0ms, Mode=Clicks Only
  • Standard restoration: Sensitivity=20, Width=2.0ms, Mode=Clicks + Crackle
  • Heavy restoration: Sensitivity=30, Width=5.0ms, Mode=Aggressive

Python Tool

Basic usage:

python vinyl_scratch_removal.py input.wav output.wav

With custom parameters:

# Conservative (only obvious clicks)
python vinyl_scratch_removal.py input.wav output.wav --mode conservative --threshold 4.0

# Standard (recommended)
python vinyl_scratch_removal.py input.wav output.wav --mode standard --threshold 3.0

# Aggressive (maximum click removal)
python vinyl_scratch_removal.py input.wav output.wav --mode aggressive --threshold 2.0 --max-width 5.0

Command-line options:

--threshold FLOAT       Detection threshold in standard deviations
                        Lower = more sensitive (default: 3.0)
                        Range: 1.0 (very sensitive) to 5.0 (conservative)

--max-width FLOAT       Maximum click width in milliseconds
                        (default: 2.0)

--mode MODE             Detection mode:
                        - conservative: Only obvious clicks
                        - standard: Balanced (default)
                        - aggressive: Maximum detection

--ar-order INT          AR model order for interpolation
                        Higher = more accurate but slower
                        (default: 20, range: 10-50)

Research Foundation

This plugin implements techniques from published research in digital audio restoration:

Key Research Papers

  1. Godsill & Rayner (1998) - "Digital Audio Restoration: A Statistical Model Based Approach"

    • Foundation for AR-based audio restoration
    • Bayesian framework for click detection
    • Statistical modeling of clean audio signals
  2. Lagrange et al. (2020) - "Restoration Based on High Order Sparse Linear Prediction"

    • Sparse AR prediction reduces computation
    • High-order models for better quality
    • Implemented in Python version
  3. Esquef et al. (2004) - "Detection of clicks using warped linear prediction"

    • Perceptually-weighted detection
    • Adaptive thresholding methods
    • Influences detection algorithm
  4. Recent (2024) - "Diffusion Models for Audio Restoration" (arXiv:2402.09821)

    • Modern deep learning approaches
    • Future research direction

See Research Findings for complete bibliography and algorithm descriptions.

Why Two Implementations?

Nyquist Language Constraints

Nyquist (LISP-based audio language) treats audio as continuous signals (mathematical functions), not discrete sample arrays. This philosophical difference has practical implications:

What Nyquist CAN do:

  • Signal-level operations (filtering, mixing, multiplication)
  • Envelope following and analysis
  • Adaptive processing
  • Fast, efficient processing

What Nyquist CANNOT do:

  • Access individual samples (audio[i])
  • Array/matrix operations (needed for AR interpolation)
  • Sample-level loops and interpolation
  • FFT/spectral editing

See Nyquist Programming Guide for detailed explanation.

Implementation Strategy

Nyquist Plugin: Uses frequency-domain approach that works within language constraints

  • Good quality through attenuation rather than interpolation
  • Fast, practical, works for 90% of cases

Python Tool: Implements "ideal" algorithm from research literature

  • True sample-level interpolation
  • Highest quality for archival restoration
  • Slower, requires external dependencies

Recommendation: Start with Nyquist plugin. Use Python tool for difficult cases or archival work.

Comparison with Other Tools

Feature Audacity Built-in This Plugin (Nyquist) This Tool (Python) iZotope RX
Quality Fair Good Excellent Excellent
Speed Fast Fast Slow Medium
Real-time preview Yes Yes No Yes
Cost Free Free Free $$$$
Ease of use Easy Easy Command-line Easy
Algorithm Simple threshold Adaptive attenuation AR interpolation ML + spectral
Preservation Fair Good Excellent Excellent
Integration Built-in Plugin Standalone Standalone

When to use each:

  • Audacity built-in: Quick, simple jobs
  • This Nyquist plugin: Most vinyl restoration tasks (recommended)
  • This Python tool: Archival-quality restoration, difficult cases
  • iZotope RX: Professional work, visual editing, budget available

Limitations

Nyquist Plugin

  1. Attenuation not removal: Reduces click amplitude rather than completely removing (language constraint)
  2. Very loud clicks: May still be faintly audible after processing
  3. High-frequency percussion: Cymbals/hi-hats may be slightly reduced on aggressive mode

Both Implementations

  1. Impulsive noise only: Designed for clicks/pops, not continuous noise (hiss, rumble, hum)
  2. Manual tuning: Different recordings need different parameters
  3. Transient preservation: May affect legitimate musical transients if set too aggressively

Python Tool

  1. Processing time: AR interpolation is CPU-intensive (not real-time)
  2. Dependencies: Requires Python 3.7+, NumPy, SciPy, soundfile
  3. No GUI: Command-line interface only

Best Practices

Before Processing

  1. Clean the record - Physical cleaning reduces scratches
  2. Test a section - Process a small section first to tune parameters
  3. Use preview - In Audacity, always preview before applying
  4. Make a backup - Save original before processing

Parameter Tuning

  1. Start conservative - Begin with low sensitivity
  2. Increase gradually - If clicks remain, increase sensitivity
  3. Check for artifacts - Listen for "watery" or "bubbling" sounds (over-processing)
  4. Adjust width - Match maximum click width to your vinyl's condition

Post-Processing

  1. Check edges - Listen to track beginnings/ends for artifacts
  2. Compare with original - A/B test to ensure quality
  3. Further processing - Consider additional noise reduction if needed
  4. Normalize - May want to normalize volume after processing

Troubleshooting

"Still hearing clicks"

  • Increase sensitivity: Try threshold 30-50 (Nyquist) or 2.0-2.5 (Python)
  • Increase max width: Try 5-10ms for larger pops
  • Use aggressive mode: Switch to aggressive detection

"Audio sounds damaged/watery"

  • Decrease sensitivity: Try threshold 5-10 (Nyquist) or 4.0-5.0 (Python)
  • Use conservative mode: Switch to conservative detection
  • Reduce max width: Try 1.0-2.0ms

"Plugin not appearing in Audacity"

  1. Check plugin file location
  2. Restart Audacity
  3. Check Plugin Manager (Tools > Plugin Manager)
  4. Enable plugin if disabled

"Python script errors"

  • Check dependencies: pip install -r requirements.txt
  • Check file format: Use WAV files (MP3/FLAC may need conversion)
  • Check Python version: Requires Python 3.7+

Contributing

Contributions welcome! Areas for improvement:

  • Deep learning-based detection and interpolation
  • Real-time processing optimization
  • GUI for Python tool
  • Additional file format support
  • LADSPA/LV2 plugin compilation

License

MIT License - See LICENSE file for details

Credits

  • Algorithm Research: Based on published DSP research (see Technical Background)
  • Implementation: Claude (Anthropic)
  • Testing: Community contributions welcome

References

  1. Godsill, S., & Rayner, P. (1998). Digital Audio Restoration: A Statistical Model Based Approach. Springer.

  2. Lagrange, M., et al. (2020). "Restoration of Click Degraded Speech and Music Based on High Order Sparse Linear Prediction." ResearchGate.

  3. Esquef, P.A.A., et al. (2004). "Detection of clicks in audio signals using warped linear prediction." IEEE.

  4. Columbia University DSP Course. "Audio Click Removal Using Linear Prediction."

  5. Various authors (2024). "Diffusion Models for Audio Restoration." arXiv:2402.09821.

Support

For issues, questions, or suggestions:

  • Open an issue on GitHub
  • Check existing issues for solutions
  • Consult Audacity forums for plugin-specific questions

Note: This is research software. While based on published algorithms, results may vary depending on your audio. Always keep original recordings as backup.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •