Intelligent EQ: Adaptive Bandpass — User Guide
Pitch-tracking adaptive filter: follows fundamental frequency or harmonics with time-varying bandpass filtering, preserving harmonic structure while removing noise and unrelated frequencies.
What this does
This script implements Intelligent Adaptive Bandpass EQ — a pitch-tracking filter that follows the fundamental frequency or its harmonics in real time. Process: (1) Pitch analysis: Track fundamental frequency (F0) using Praat's pitch detection. (2) Target calculation: Apply multiplier (e.g., 2.0 for 2nd harmonic) and offset to F0. (3) Adaptive filtering: Apply time-varying bandpass filter centered on target frequency. (4) OLA processing: Use overlap-add method with Hanning windows for smooth transitions. (5) Unvoiced handling: Bypass, attenuate, or mute non-pitched regions. Result: Clean extraction of harmonic content that follows pitch variations naturally.
Key Features:
- 6 Processing Presets: Fundamental extraction, 2nd/3rd harmonic focus, subharmonic, wide harmonic, noise reduction
- Real-time Pitch Tracking: Adaptive filtering follows F0 variations
- Harmonic Multiplier: Target any harmonic (1.0=F0, 2.0=2nd harmonic, 0.5=subharmonic)
- Flexible Bandwidth: Fixed Hz or relative to center frequency
- Unvoiced Handling: Three strategies for non-pitched regions
- Quality Settings: Draft/Standard/High for speed/quality tradeoff
- Comprehensive Visualization: Spectrograms, pitch tracks, waveforms, statistics
- Strict OLA Implementation: 50% overlap Hanning windows for artifact-free output
Technical Implementation: (1) Pitch detection: Praat's To Pitch with smoothing. (2) Target calculation: targetFreq = F0 × multiplier + offset. (3) Bandwidth calculation: Fixed Hz or relative (BW = center × fraction). (4) Filter design: Hann bandpass filter with specified rolloff. (5) OLA processing: Window duration based on quality setting, 50% overlap, Hanning window. (6) Frame processing: For each window: extract segment, apply filter if voiced, handle unvoiced per mode, add to output with overlap. (7) Visualization: Original/filtered spectrograms, F0/target tracks, waveforms, statistics.
Quick start
- In Praat, select exactly one Sound object (mono or stereo).
- Run script… →
Intelligent_EQ_Adaptive_Bandpass.praat. - Choose Preset (Fundamental Extraction, 2nd Harmonic Focus, etc.) or Custom.
- Set Pitch Tracking range (75-500 Hz typical for speech/singing).
- Set F0 multiplier (1.0 = fundamental, 2.0 = octave up, 0.5 = octave down).
- Choose Bandwidth mode: Fixed Hz or Relative to center frequency.
- Set Unvoiced mode: Bypass, Attenuate, or Mute non-pitched regions.
- Choose Quality: Draft (fast), Standard, High (best).
- Enable Show_visualization for comprehensive graphical output.
- Click OK — adaptive filtering applied, visualization shown.
Adaptive Filtering Theory
Pitch Tracking & Smoothing
🎵 Praat's Pitch Detection Algorithm
Method: Autocorrelation-based fundamental frequency estimation
Voicing detection: Based on periodicity strength; frames with undefined pitch = unvoiced
Target Frequency Calculation
🎯 Harmonic Relationship Control
Musical interpretation: Multiplier creates harmonic relationship preserved through pitch changes
Bandwidth Calculation Modes
📏 Fixed vs Relative Bandwidth
Mode 1: Fixed bandwidth (Hz)
Mode 2: Relative bandwidth (fraction of center)
Overlap-Add (OLA) Processing
🔄 Artifact-Free Time-Varying Filtering
Window parameters by quality:
| Quality | Window Duration | Hop Size | Overlap | Use Case |
|---|---|---|---|---|
| Draft | 60 ms | 30 ms | 50% | Fast processing, offline analysis |
| Standard | 40 ms | 20 ms | 50% | General purpose, good quality |
| High | 25 ms | 12.5 ms | 50% | Best quality, musical applications |
Unvoiced Region Handling
Hann Bandpass Filter Properties
- Windowed sinc implementation: Finite impulse response (FIR)
- Linear phase: No phase distortion (important for music)
- Rolloff smoothness: Controls transition bandwidth (default 50 Hz)
- Passband ripple: Minimal with Hann window
- Stopband attenuation: Good rejection outside passband
- Computation: Efficient convolution implementation
Mathematical formulation:
Preset Applications
Preset 1: Fundamental Extraction
🎤 Clean Vocal Extraction
Settings: multiplier=1.0, relative BW=0.4, mute unvoiced, smoothing=10Hz
Effect: Isolates fundamental frequency, removes harmonics and noise
Use: Vocal cleaning, pitch analysis preprocessing, telephone effect
Audio result: Pure, sine-like tone following pitch contour
Preset 2: 2nd Harmonic Focus
🎵 Octave Up Enhancement
Settings: multiplier=2.0, relative BW=0.3, attenuate unvoiced, smoothing=12Hz
Effect: Emphasizes 2nd harmonic (octave above fundamental)
Use: Creating artificial octave effects, harmonic enhancement
Audio result: Bright, focused tone one octave above original
Preset 3: 3rd Harmonic Focus
🎶 12th Above Emphasis
Settings: multiplier=3.0, relative BW=0.25, attenuate unvoiced, smoothing=12Hz
Effect: Isolates 3rd harmonic (perfect 12th = octave+fifth)
Use: Creating harmonic melodies, interval-based effects
Audio result: Distinct harmonic line following pitch ×3
Preset 4: Subharmonic (Octave Below)
🔉 Bass Enhancement
Settings: multiplier=0.5, relative BW=0.5, attenuate unvoiced, smoothing=15Hz
Effect: Creates subharmonic one octave below fundamental
Use: Bass enhancement, subharmonic synthesis, fattening sounds
Audio result: Deep, rich tone following pitch ÷2
Preset 5: Wide Harmonic Preserve
🎚️ Gentle Harmonic Filtering
Settings: multiplier=1.0, relative BW=2.0, bypass unvoiced, smoothing=15Hz
Effect: Wide bandpass around fundamental, preserves harmonic structure
Use: Gentle noise reduction, mild filtering, preserving natural timbre
Audio result: Natural sound with reduced extreme frequencies
Preset 6: Noise Reduction
🔇 Intelligent Noise Removal
Settings: multiplier=1.0, fixed BW=150Hz, attenuate -24dB unvoiced, smoothing=10Hz
Effect: Tight bandpass around pitch, strong attenuation of non-pitched noise
Use: Cleaning noisy recordings, speech enhancement, restoration
Audio result: Clean pitched content with reduced background noise
Preset 7: Custom
🔧 Manual Configuration
Settings: User-defined parameters
Effect: Tailored to specific needs
Use: Experimentation, specific applications, research
Flexibility: Full control over all parameters
Parameters Explained
Pitch Tracking Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Minimum_pitch_(Hz) | 75 | 50-200 | Lowest expected fundamental frequency |
| Maximum_pitch_(Hz) | 500 | 200-1000 | Highest expected fundamental frequency |
| Smoothing_(Hz) | 10 | 0-50 | Bandwidth of pitch smoothing filter |
Harmonic/Octave Control
| Parameter | Default | Range | Description |
|---|---|---|---|
| F0_multiplier | 1.0 | 0.1-10.0 | Multiply F0 by this value (1.0=F0, 2.0=octave up) |
| F0_offset_(Hz) | 0.0 | -1000 to 1000 | Add this frequency after multiplication |
Filter Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Bandwidth_val | 100 | 20-2000 | Bandwidth value (Hz or fraction) |
| Bandwidth_mode | Fixed | Fixed/Relative | Hz or fraction of center frequency |
| Rolloff_smoothness | 50 | 10-200 | Transition bandwidth of filter (Hz) |
Unvoiced Handling
| Parameter | Default | Options | Description |
|---|---|---|---|
| Unvoiced_mode | Attenuate | Bypass/Attenuate/Mute | How to handle non-pitched regions |
| Unvoiced_attenuation_(dB) | -18 | -60 to 0 | Attenuation for unvoiced regions (if attenuate mode) |
Quality/Speed
| Parameter | Default | Options | Window Size | Use Case |
|---|---|---|---|---|
| Quality | Standard | Draft/Standard/High | 60/40/25 ms | Speed vs quality tradeoff |
Parameter Guidelines by Application
- Speech (male): Min pitch=75Hz, Max pitch=250Hz, Smoothing=15Hz
- Speech (female): Min pitch=150Hz, Max pitch=400Hz, Smoothing=12Hz
- Singing (tenor): Min pitch=80Hz, Max pitch=350Hz, Smoothing=10Hz
- Singing (soprano): Min pitch=200Hz, Max pitch=800Hz, Smoothing=8Hz
- Violin: Min pitch=200Hz, Max pitch=1000Hz, Smoothing=5Hz
- Cello: Min pitch=60Hz, Max pitch=500Hz, Smoothing=10Hz
- Trumpet: Min pitch=150Hz, Max pitch=600Hz, Smoothing=8Hz
- Fundamental extraction: Relative BW 0.3-0.5
- Harmonic enhancement: Relative BW 0.2-0.3
- Noise reduction: Fixed BW 100-200 Hz
- Natural preservation: Relative BW 1.0-2.0
- Telephone effect: Fixed BW 300-600 Hz
Applications
Vocal Processing & Cleaning
Use case: Remove background noise from vocal recordings
Settings: Noise Reduction preset, adjust bandwidth for voice type
Workflow: Process vocal track, mix back with dry signal to retain some naturalness
Harmonic Enhancement & Effects
Use case: Create artificial octave or harmonic effects
Settings: 2nd/3rd Harmonic Focus, mix with original
Creative potential: Parallel processing with different multipliers
Source Separation
Use case: Extract monophonic instrument from mix
Settings: Fundamental Extraction with appropriate pitch range
Limitations: Works best when target is loudest pitched source
Pitch Analysis Preprocessing
Use case: Clean signal before pitch detection algorithms
Settings: Fundamental Extraction with mute unvoiced
Benefit: Reduces pitch detection errors from noise/harmonics
Creative Sound Design
Use case: Dynamic filtering effects
Settings: Vary multiplier over time, use extreme bandwidths
Experimentation: Multiplier automation, unvoiced mode switching
Audio Restoration
Use case: Reduce specific noise types (buzz, hum)
Settings: Fixed bandwidth around noise frequency
Technique: Invert filtered result, mix to cancel noise
Visualization Analysis
📊 Understanding the Visualization
| Panel | Content | Purpose |
|---|---|---|
| Title | Script name, filename, preset | Context |
| Original Spectrogram | Input spectrogram with pitch (blue) and target (yellow) overlays | Show pitch tracking accuracy and target calculation |
| Filtered Spectrogram | Output spectrogram with target overlay (green) | Show filtering effect and what frequencies were preserved |
| Pitch + Target Frequency | Time plots of F0 (blue) and target frequency (orange) | Compare original pitch vs filter center frequency |
| Waveform Comparison | Original (left) vs filtered (right) waveforms | Show time-domain effect of filtering |
| Legend & Stats | Color key, statistics, parameters | Interpretation reference |
| Time Axis | Timeline with tick marks | Temporal reference |
Color coding: Blue = detected F0, Orange/Yellow = calculated target, Green = target on filtered spectrogram
Troubleshooting
Causes: Rapid pitch changes, window size too large, excessive smoothing
Solutions: Reduce window size (use High quality), decrease smoothing, check pitch range
Causes: Pitch detection failures, wrong pitch range, insufficient smoothing
Solutions: Adjust min/max pitch parameters, increase smoothing, check visualization
Causes: Bandwidth too narrow, unvoiced mode too aggressive
Solutions: Increase bandwidth, use bypass/gentle attenuation for unvoiced
Causes: Long audio, High quality setting, old computer
Solutions: Use Draft quality for long files, process shorter segments, upgrade hardware
Causes: All frames unvoiced, mute mode too aggressive, pitch detection failure
Solutions: Check pitch detection visualization, adjust pitch range, use bypass mode
Implementation Details
Script Architecture
Key Variables & Objects
| Variable | Type | Purpose |
|---|---|---|
| originalID | Object ID | Original Sound object |
| monoSource | Sound | Mono version for processing |
| pitch | Pitch | Smoothed pitch contour |
| outputSound | Sound | Filtered output |
| windowDur | Real | Window duration (0.025-0.06 s) |
| hopDur | Real | Hop size (50% of windowDur) |
| numFrames | Integer | Number of OLA frames |
| attenFactor | Real | Linear attenuation factor |
| currentPitch | Real | Pitch at frame midpoint |
| isVoiced | Boolean | Voiced/unvoiced decision |
| targetFreq | Real | Filter center frequency |
| effectiveBW | Real | Calculated bandwidth |
| lowBound/highBound | Real | Filter cutoff frequencies |
Critical Processing Loop
Visualization Components
- Title: Outer viewport 0-9 × 0-0.8
- Original Spectrogram: 0-8 × 0.7-2.5
- Filtered Spectrogram: 0-8 × 2.6-4.4
- Pitch+Target Plot: 0-8 × 4.5-5.7
- Waveform Comparison: Left: 0-4 × 5.8-6.6, Right: 4-8 × 5.8-6.6
- Legend & Stats: 0-8 × 6.7-7.4
- Time Axis: 0-8 × 7.4-7.7
- F0 contour: RGB(0.3, 0.6, 0.9) - Blue
- Target frequency: RGB(0.9, 0.5, 0.2) - Orange
- Pitch overlay (original spec): RGB(0.2, 0.9, 0.3) - Green
- Target overlay (filtered spec): RGB(0.2, 1.0, 0.4) - Bright green
- Original waveform: RGB(0.5, 0.5, 0.7) - Gray-blue
- Filtered waveform: RGB(0.5, 0.7, 0.5) - Green-gray
Example Use Cases
Example 1: Vocal Cleanup
🎤 Removing Air Conditioning Hum from Speech
Problem: Speech recording with 60 Hz AC hum and broadband noise
Solution:
- Select Noise Reduction preset
- Set minimum_pitch = 75 Hz, maximum_pitch = 300 Hz
- Set F0_multiplier = 1.0, F0_offset = 0
- Use Fixed bandwidth = 120 Hz
- Set unvoiced_mode = Attenuate, unvoiced_attenuation = -20 dB
- Quality = Standard
- Enable visualization to verify pitch tracking
Result: Clean speech with reduced hum and background noise. Consonants slightly attenuated but intelligible.
Example 2: Harmonic Melody Creation
🎵 Creating a Parallel Fifth Harmony
Goal: Generate harmony line a perfect fifth above vocal melody
Solution:
- Select Custom preset
- Set F0_multiplier = 1.5 (perfect fifth ratio)
- Use Relative bandwidth = 0.25
- Set unvoiced_mode = Bypass
- Quality = High for musical quality
- Process vocal, mix 50% with original
Result: Rich harmony following melody at perfect fifth interval. Natural sounding because filter tracks pitch variations.
Example 3: Instrument Isolation
🎻 Extracting Violin from Ensemble
Problem: Violin mixed with piano and cello
Solution:
- Select Fundamental Extraction preset
- Set minimum_pitch = 200 Hz, maximum_pitch = 1000 Hz (violin range)
- Set Relative bandwidth = 0.3
- Set unvoiced_mode = Attenuate (-12 dB)
- Quality = High for clean extraction
- Apply noise gate after processing
Result: Isolated violin line with reduced piano/cello interference. Works best when violin is prominent.
Example 4: Creative Sound Design
🎛️ Dynamic Filter Sweep Effect
Goal: Create evolving filter that follows pitch but changes harmonic relationship
Solution:
- Process audio multiple times with different multipliers
- Run 1: multiplier = 1.0 (fundamental)
- Run 2: multiplier = 2.0 (octave)
- Run 3: multiplier = 1.5 (fifth)
- Crossfade between results over time
- Add reverb to blended output
Result: Evolving harmonic texture that moves between intervals while tracking pitch.