Dynamic Spectral Hole — User Guide

Pitch-adaptive spectral filtering: analyzes fundamental frequency, creates moving notch filter that tracks pitch to remove harmonics or fundamental, producing hollow/filtered timbres for experimental sound design.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.1 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script creates pitch-adaptive spectral notch filter — removes specific frequency band determined by audio's fundamental frequency. Process: (1) Analyze pitch using Praat's pitch detection (finds mean F0), (2) Define notch range based on F0 (lower bound = mean F0, upper bound = mean F0 × octave_multiplier), (3) Convert audio to frequency domain via FFT, (4) Attenuate frequencies in notch range (multiply by notch_attenuation factor, typically 0.01-0.3), (5) Convert back to time domain. Result: Removes fundamental and/or lower harmonics, creates hollow/filtered timbre, useful for removing voice fundamental, isolating upper partials, or creating robotic/filtered effects. Unlike static notch filters (fixed frequencies), this adapts to audio's pitch content.

What is spectral notch filtering? Notch filter = narrow band-reject filter that attenuates specific frequency range while passing everything else. In frequency domain: spectrum multiplied by attenuation factor in notch band. Dynamic vs static: Static notch (traditional) removes fixed frequency (e.g., 440 Hz always). Dynamic notch (this script) tracks audio pitch — if mean pitch = 150 Hz, notch centers around 150 Hz; if pitch = 300 Hz, notch moves to 300 Hz. Applications: Voice processing (remove fundamental for telephone effect), harmonic manipulation (isolate breathiness vs tone), music analysis (hear effect of removing fundamental), timbral experiments (create unnatural filtered sounds). Pitch tracking advantage: Single preset works across different speakers/instruments (adapts to their pitch range automatically).

Quick start

  1. In Praat, select Sound object (speech or music).
  2. Run script…Dynamic_Spectral_Hole.praat.
  3. Choose Processing_preset (try "Voice fundamental (speech)" for speech, "Music fundamental" for music).
  4. For first use: Keep default settings (presets override manual parameters).
  5. Click OKWait for processing (no progress indicator, be patient).
  6. New Sound object created: originalname_pitch_notched, auto-plays if enabled.
  7. Compare with original to hear spectral hole effect.
Quick tip: Test on short clips first (5-15 seconds) to verify settings before processing long files. For speech: "Voice fundamental" removes bass/body (creates thin, tinny voice). For music: "Music fundamental" removes low pitch energy (emphasizes upper harmonics/breathiness). Attenuation parameter key: 0.01 = aggressive (99% removal), 0.3 = gentle (70% removal). Lower values create more dramatic effect. Octave multiplier determines notch width: 1.5 = narrow notch (just fundamental), 4-8 = wide notch (fundamental + harmonics). No visual progress — script appears frozen during FFT processing (this is normal, wait for completion).
Important: LONG PROCESSING TIME especially on files >30 seconds. FFT operations computationally intensive. Script does not show progress during processing. Pitch analysis required: Source audio must have detectable pitch (works on: speech, singing, monophonic instruments, harmonic content). Does not work well on: noise, percussion, non-pitched sounds (pitch detection fails → unpredictable notch placement). Stereo handling: Script works on mono or stereo (processes both channels identically). Keep intermediate objects = 0: Pitch and Spectrum objects automatically removed (saves memory). Set to 1 only for debugging.

Presets

Available Presets

1. Custom settings

Uses manual parameters. Set all values yourself for full control. Good for experimentation or specific use cases not covered by presets.

Default custom values: Time step 0.1s, Pitch 75-600 Hz, Octave multiplier 2, Attenuation 0.1

2. Voice fundamental (speech)

Removes speech fundamental frequency. Time step: 0.01s (detailed pitch tracking), Pitch range: 75-300 Hz (typical speech), Octave multiplier: 1.5 (narrow notch, just F0), Attenuation: 0.05 (95% removal).

Effect: Thin, tinny voice. Removes vocal warmth/body. Creates telephone-like quality. Breathiness/consonants remain. For: Robotic effects, filtered vocals, de-emphasis of fundamental, highlighting formants.

3. Voice harmonics (speech)

Removes fundamental + lower harmonics. Time step: 0.01s, Pitch range: 75-300 Hz, Octave multiplier: 4 (wide notch up to 4× F0), Attenuation: 0.2 (80% removal).

Effect: Very hollow voice. Removes fundamental + first few harmonics. Emphasizes high formants and sibilants. Whisper-like quality. For: Ghostly voices, extreme filtering, isolating high-frequency speech components.

4. Music fundamental

Removes musical fundamental. Time step: 0.05s, Pitch range: 50-800 Hz (wider than speech), Octave multiplier: 2 (fundamental + octave), Attenuation: 0.1 (90% removal).

Effect: Hollow instrument tone. Removes pitch but retains timbre/harmonics. Creates "missing fundamental" illusion (brain fills in removed pitch). For: Experimental music, harmonic analysis, timbral manipulation.

5. Music upper partials

Removes wide range including many harmonics. Time step: 0.05s, Pitch range: 50-800 Hz, Octave multiplier: 8 (very wide notch up to 8× F0), Attenuation: 0.15 (85% removal).

Effect: Extreme filtering. Removes fundamental and multiple harmonics. Leaves only highest partials and noise components. For: Radical sound design, isolating breath/bow noise, creating ethereal textures.

6. Aggressive notch

Maximum removal with moderate bandwidth. Time step: 0.01s, Pitch range: 75-600 Hz, Octave multiplier: 3 (fundamental + harmonics), Attenuation: 0.01 (99% removal).

Effect: Nearly complete removal of notch band. Dramatic hollowing. Extreme timbral change. For: Special effects, radical filtering, demonstrating notch effect clearly.

7. Gentle notch

Subtle filtering with partial removal. Time step: 0.1s, Pitch range: 75-600 Hz, Octave multiplier: 2, Attenuation: 0.3 (70% removal).

Effect: Mild hollowing. Noticeable but not extreme. Retains more naturalness. For: Subtle timbral shaping, corrective filtering, musical applications where extreme effect unwanted.

Parameters

Pitch Analysis Parameters

Parameter Default Description
time_step 0.1 s Pitch analysis frame rate. Smaller = more detailed tracking (0.01s for speech, 0.05s for music). Affects processing time but not notch frequency (uses mean pitch over entire file).
minimum_pitch 75 Hz Lowest expected pitch. Speech: 75 Hz (male), Music: 50 Hz (bass instruments). Must be below actual audio pitch for accurate detection.
maximum_pitch 600 Hz Highest expected pitch. Speech: 300 Hz (female), Music: 800 Hz (soprano/high instruments). Must be above actual audio pitch.

Notch Range Parameters

Parameter Default Description
octave_multiplier 2 Defines notch upper bound: upper_freq = mean_pitch × multiplier. Values: 1.5 (narrow, just fundamental), 2-3 (fundamental + few harmonics), 4-8 (wide, many harmonics). Higher = wider notch.
notch_attenuation 0.1 Multiplier for frequencies in notch band (0 = complete removal, 1 = no effect). Typical: 0.01-0.05 (aggressive 95-99% removal), 0.1-0.2 (strong 80-90% removal), 0.3-0.5 (gentle 50-70% removal).

Spectrum Parameters

Parameter Default Description
fast_fourier no (0) Use Fast Fourier Transform for spectrum conversion. "no" = standard DFT (slower, more accurate). "yes" = FFT (faster, requires power-of-2 length). Usually keep at "no" unless processing very long files.

Output Options

Parameter Default Description
scale_peak 0.99 Normalize output to this peak amplitude. 0.99 prevents clipping. Lower values (0.7-0.9) reduce overall level. 1.0 = full scale (may clip).
play_after_processing 1 (yes) Automatically play processed audio when complete. Useful for immediate comparison. Set to 0 to skip playback.
keep_intermediate_objects 0 (no) Keep Pitch and Spectrum objects after processing. Usually set to 0 (auto-cleanup). Set to 1 for debugging or manual inspection of pitch/spectrum.
Parameter tips: Pitch range critical: If range too narrow, pitch detection fails → wrong notch frequency. Check original audio's pitch first (Praat: Sound → Periodicity → To Pitch). Octave multiplier experimentation: Try 1.5, 2, 3, 4, 6, 8 to hear different notch widths (each value creates distinct timbral effect). Attenuation sweet spots: 0.05 (aggressive, clear effect), 0.1 (balanced), 0.2-0.3 (subtle, more natural). Values >0.5 create very mild effect.

Applications

Voice Processing

Music Production

Sound Design

Research & Analysis

Processing chain ideas: Combine with other effects for complex processing:
  • Notch + Reverb: Hollow vocal → reverb creates ghostly presence (space + filtering)
  • Notch + Pitch shift: Remove fundamental → pitch shift → re-add fundamental at different pitch (harmonic transplanting)
  • Notch + Distortion: Hollow sound → distortion adds new harmonics (fills spectral hole with distortion artifacts)
  • Notch + Time-stretch: Remove fundamental → stretch → creates ethereal, filtered drone
  • Parallel processing: Mix notched (20%) with original (80%) for subtle hollowing without complete removal

Technical Details

Processing Pipeline

Step 1: Pitch Analysis To Pitch: time_step, minimum_pitch, maximum_pitch mean_pitch = Get mean: 0, 0, "Hertz" (Calculates average F0 over entire file) Step 2: Define Notch Range lower_bound = mean_pitch upper_bound = mean_pitch × octave_multiplier Example: mean_pitch = 150 Hz, octave_multiplier = 2 Notch range: 150-300 Hz Step 3: Spectral Conversion spectrum = To Spectrum: fast_fourier (FFT: time domain → frequency domain) Step 4: Apply Notch Filter For each frequency bin: if frequency ≥ lower_bound AND frequency ≤ upper_bound: magnitude = magnitude × notch_attenuation else: magnitude = unchanged Step 5: Time Domain Conversion sound = To Sound (Inverse FFT: frequency domain → time domain) Step 6: Normalize Scale peak: scale_peak (default 0.99)

Notch Filter Mathematics

Frequency response H(f): H(f) = 1 if f < f_low or f > f_high H(f) = notch_attenuation if f_low ≤ f ≤ f_high Where: f_low = mean_pitch f_high = mean_pitch × octave_multiplier Attenuation in dB: attenuation_dB = 20 × log₁₀(notch_attenuation) Examples: 0.01 → -40 dB (very aggressive) 0.05 → -26 dB (aggressive) 0.1 → -20 dB (strong) 0.2 → -14 dB (moderate) 0.3 → -10 dB (gentle) Notch width in octaves: width_octaves = log₂(octave_multiplier) Examples: multiplier 2 → 1 octave multiplier 4 → 2 octaves multiplier 8 → 3 octaves

Computational Complexity

Why processing is slow: FFT operations O(N log N) complexity where N = number of samples. For 30-second audio at 44100 Hz: N = 1,323,000 samples. FFT + inverse FFT both required. Praat's To Spectrum and To Sound are computationally expensive. No optimization available — inherent to frequency-domain processing. For very long files (>60 seconds), consider: (1) Split into segments, process separately, concatenate results, (2) Use faster computer, (3) Accept long processing time, (4) Reduce sample rate before processing (resample to 22050 Hz → faster but lower quality).

Tips & Troubleshooting

Optimization Strategies

Reducing processing time:
  • Test on short clips: Extract 5-10 second segment, process, verify effect, then process full file
  • Lower sample rate: Resample audio to 22050 Hz before processing (2× faster, acceptable quality loss for effects)
  • Segment processing: Split long file into 30-second chunks, process separately, concatenate (allows progress monitoring)
  • Coarser pitch analysis: Increase time_step to 0.2 (faster pitch analysis, minimal effect on notch placement since mean pitch used)

Common Issues

Problem: No audible effect
Cause: Notch_attenuation too high (e.g., 0.8-1.0) — minimal removal
Solution: Lower notch_attenuation to 0.05-0.2 for clear effect
Problem: Entire audio quiet/filtered
Cause: Pitch detection failed → notch placed incorrectly, or notch too wide (high octave_multiplier)
Solution: Verify pitch range matches audio (listen to Pitch object if kept). Reduce octave_multiplier to 1.5-2.
Problem: Metallic artifacts/ringing
Cause: Spectral filtering can introduce phase distortion/artifacts
Solution: Increase notch_attenuation (gentler removal), or use narrower notch (lower octave_multiplier). Some artifacts inherent to frequency-domain processing.
Problem: Script appears frozen
Cause: FFT processing in progress (no visual feedback)
Solution: Wait patiently. Check Praat status bar (bottom) — if not frozen, processing continues. For very long files, can take 1-2 minutes.
Problem: Works on speech but not music
Cause: Speech pitch range (75-300 Hz) too narrow for music
Solution: Use Music presets with wider range (50-800 Hz). For polyphonic music, pitch detection may fail (script assumes monophonic/dominant pitch).