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.

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

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:

What is adaptive bandpass filtering? Traditional EQ: Fixed frequency bands. Adaptive filter: Frequency follows audio content. Pitch-tracking filter: Center frequency tracks fundamental or harmonic. Applications: (1) Source separation: Extract vocal/instrument from mix. (2) Noise reduction: Remove non-harmonic noise. (3) Harmonic enhancement: Isolate specific harmonics. (4) Pitch correction preprocessing: Clean signal before pitch detection. (5) Creative effects: Dynamic filtering effects. Advantages: (1) Content-aware: Responds to audio content. (2) Natural: Preserves pitch variations. (3) Flexible: Target any harmonic relationship. (4) High quality: OLA minimizes artifacts. (5) Intelligent: Distinguishes voiced/unvoiced.

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

  1. In Praat, select exactly one Sound object (mono or stereo).
  2. Run script…Intelligent_EQ_Adaptive_Bandpass.praat.
  3. Choose Preset (Fundamental Extraction, 2nd Harmonic Focus, etc.) or Custom.
  4. Set Pitch Tracking range (75-500 Hz typical for speech/singing).
  5. Set F0 multiplier (1.0 = fundamental, 2.0 = octave up, 0.5 = octave down).
  6. Choose Bandwidth mode: Fixed Hz or Relative to center frequency.
  7. Set Unvoiced mode: Bypass, Attenuate, or Mute non-pitched regions.
  8. Choose Quality: Draft (fast), Standard, High (best).
  9. Enable Show_visualization for comprehensive graphical output.
  10. Click OK — adaptive filtering applied, visualization shown.
Quick tip: Start with Fundamental Extraction preset for vocal cleanup. Use Standard quality for good balance of speed/quality. Check visualization to verify pitch tracking (blue line should follow pitch). Adjust minimum_pitch/maximum_pitch to match your audio (speech: 75-300 Hz, singing: 80-600 Hz). For harmonic enhancement, try 2nd Harmonic Focus (multiplier=2.0). For noise reduction, use Noise Reduction preset with attenuate unvoiced. The output sound retains pitch variations naturally — filter center follows F0. Listen for clean harmonic extraction with reduced noise/unwanted frequencies.
Important: MONO CONVERSION: Stereo inputs converted to mono (averaged). PITCH DETECTION REQUIREMENTS: Works best with clear pitched content (singing, monophonic instruments). May struggle with noisy/unpitched audio. REAL-TIME ADAPTATION: Filter updates every window (25-60ms) — rapid pitch changes may cause lag. BANDWIDTH CONSIDERATIONS: Too narrow = artificial/"telephone" sound, too wide = insufficient filtering. UNVOICED HANDLING: Attenuate/Mute modes affect consonants/breath sounds. PROCESSING TIME: Scales with duration and quality setting (High = 4× slower than Draft). NYQUIST LIMIT: Target frequency limited to sample_rate/2 - 100 Hz. ARTIFACTS: OLA minimizes but may occur at rapid transitions.

Adaptive Filtering Theory

Pitch Tracking & Smoothing

🎵 Praat's Pitch Detection Algorithm

Method: Autocorrelation-based fundamental frequency estimation

PARAMETERS: Time step = hopDur/2 (half window for overlap) Minimum pitch = 75 Hz (adjust based on audio) Maximum pitch = 500 Hz (adjust based on audio) SMOOTHING: Applied after initial detection Smoothing (Hz) = bandwidth of smoothing filter Higher = smoother but slower response OUTPUT: Time-varying F0(t) with voiced/unvoiced decisions

Voicing detection: Based on periodicity strength; frames with undefined pitch = unvoiced

Target Frequency Calculation

🎯 Harmonic Relationship Control

BASIC FORMULA: targetFreq(t) = F0(t) × multiplier + offset MULTIPLIER EXAMPLES: 1.0 = Fundamental frequency (F0) 2.0 = 2nd harmonic (octave above) 3.0 = 3rd harmonic (perfect 12th above) 0.5 = Subharmonic (octave below) 1.5 = Perfect fifth above (3/2 ratio) OFFSET: Additional fixed frequency shift (Hz) Useful for formant shifting or fixed offset CLAMPING: targetFreq clamped to [20 Hz, Nyquist - 100 Hz]

Musical interpretation: Multiplier creates harmonic relationship preserved through pitch changes

Bandwidth Calculation Modes

📏 Fixed vs Relative Bandwidth

Mode 1: Fixed bandwidth (Hz)

Parameters: bandwidth_val = constant width in Hz Calculation: lowBound = targetFreq - bandwidth_val/2 highBound = targetFreq + bandwidth_val/2 Characteristics: - Constant absolute width - Works well for noise reduction - May be too narrow at low frequencies - May be too wide at high frequencies

Mode 2: Relative bandwidth (fraction of center)

Parameters: bandwidth_val = fractional width (e.g., 0.4 = 40% of center) Calculation: effectiveBW = targetFreq × bandwidth_val lowBound = targetFreq - effectiveBW/2 highBound = targetFreq + effectiveBW/2 Characteristics: - Proportional to center frequency - Constant Q (quality factor) - Musical: preserves harmonic relationships - Recommended for harmonic extraction

Overlap-Add (OLA) Processing

🔄 Artifact-Free Time-Varying Filtering

Window parameters by quality:

QualityWindow DurationHop SizeOverlapUse Case
Draft60 ms30 ms50%Fast processing, offline analysis
Standard40 ms20 ms50%General purpose, good quality
High25 ms12.5 ms50%Best quality, musical applications
PROCESSING PIPELINE: FOR each frame i: 1. Extract window: [frameStart, frameEnd] with Hanning taper 2. Determine voiced/unvoiced at frame midpoint 3. IF voiced: - Calculate targetFreq for this frame - Calculate bandwidth bounds - Apply Hann bandpass filter ELSE: - Apply unvoiced handling (bypass/attenuate/mute) 4. Add to output with overlap HAN WINDOW PROPERTIES: w[n] = 0.5 × (1 - cos(2πn/(N-1))) Perfect reconstruction with 50% overlap Good frequency resolution/time localization tradeoff

Unvoiced Region Handling

THREE STRATEGIES: 1. BYPASS (unvoiced_mode = 1): Output = Original (unfiltered) Use: Preserve consonants, breath sounds Result: Natural but includes noise 2. ATTENUATE (unvoiced_mode = 2): Output = Original × attenFactor attenFactor = 10^(unvoiced_attenuation/20) Use: Reduce noise while preserving some presence Result: Cleaner but may sound unnatural if overdone 3. MUTE (unvoiced_mode = 3): Output = 0 (silence) Use: Maximum noise reduction, robotic effects Result: Very clean but may remove desired sounds RECOMMENDATION: Speech: Attenuate with -12 to -18 dB Singing: Bypass or slight attenuation Noise reduction: Attenuate or mute

Hann Bandpass Filter Properties

Praat's Filter (pass Hann band) characteristics:
  • 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:

h[n] = sinc(2×f_c×n) × w[n] (bandpass version) WHERE: f_c = center frequency w[n] = Hann window sinc(x) = sin(πx)/(πx)

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

ParameterDefaultRangeDescription
Minimum_pitch_(Hz)7550-200Lowest expected fundamental frequency
Maximum_pitch_(Hz)500200-1000Highest expected fundamental frequency
Smoothing_(Hz)100-50Bandwidth of pitch smoothing filter

Harmonic/Octave Control

ParameterDefaultRangeDescription
F0_multiplier1.00.1-10.0Multiply F0 by this value (1.0=F0, 2.0=octave up)
F0_offset_(Hz)0.0-1000 to 1000Add this frequency after multiplication

Filter Parameters

ParameterDefaultRangeDescription
Bandwidth_val10020-2000Bandwidth value (Hz or fraction)
Bandwidth_modeFixedFixed/RelativeHz or fraction of center frequency
Rolloff_smoothness5010-200Transition bandwidth of filter (Hz)

Unvoiced Handling

ParameterDefaultOptionsDescription
Unvoiced_modeAttenuateBypass/Attenuate/MuteHow to handle non-pitched regions
Unvoiced_attenuation_(dB)-18-60 to 0Attenuation for unvoiced regions (if attenuate mode)

Quality/Speed

ParameterDefaultOptionsWindow SizeUse Case
QualityStandardDraft/Standard/High60/40/25 msSpeed vs quality tradeoff

Parameter Guidelines by Application

For different audio types:
  • 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
Bandwidth recommendations:
  • 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

PanelContentPurpose
TitleScript name, filename, presetContext
Original SpectrogramInput spectrogram with pitch (blue) and target (yellow) overlaysShow pitch tracking accuracy and target calculation
Filtered SpectrogramOutput spectrogram with target overlay (green)Show filtering effect and what frequencies were preserved
Pitch + Target FrequencyTime plots of F0 (blue) and target frequency (orange)Compare original pitch vs filter center frequency
Waveform ComparisonOriginal (left) vs filtered (right) waveformsShow time-domain effect of filtering
Legend & StatsColor key, statistics, parametersInterpretation reference
Time AxisTimeline with tick marksTemporal reference

Color coding: Blue = detected F0, Orange/Yellow = calculated target, Green = target on filtered spectrogram

Troubleshooting

Problem: Artifacts/clicks in output
Causes: Rapid pitch changes, window size too large, excessive smoothing
Solutions: Reduce window size (use High quality), decrease smoothing, check pitch range
Problem: Filter doesn't track pitch correctly
Causes: Pitch detection failures, wrong pitch range, insufficient smoothing
Solutions: Adjust min/max pitch parameters, increase smoothing, check visualization
Problem: Output sounds artificial/robotic
Causes: Bandwidth too narrow, unvoiced mode too aggressive
Solutions: Increase bandwidth, use bypass/gentle attenuation for unvoiced
Problem: Processing takes too long
Causes: Long audio, High quality setting, old computer
Solutions: Use Draft quality for long files, process shorter segments, upgrade hardware
Problem: No output/silent result
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

INTELLIGENT_EQ_ADAPTIVE_BANDPASS.PRAAT ├── INPUT VALIDATION │ └── Check single Sound selection, duration > 0.05s │ ├── USER PARAMETERS FORM │ └── 7 presets + custom, pitch tracking, harmonic control, │ filter params, unvoiced handling, quality, output options │ ├── PRESET APPLICATION │ └── Override parameters for each preset │ ├── SETUP │ └── Calculate window/hop sizes, display info │ ├── STEP 1: PREPARE SOURCE │ └── Convert stereo to mono if needed │ ├── STEP 2: PITCH ANALYSIS │ └── To Pitch → Smooth → statistics collection │ ├── STEP 3: OLA PROCESSING (CORE) │ └── For each frame: │ ├── Extract Hanning window │ ├── Determine voiced/unvoiced at midpoint │ ├── If voiced: calculate target → filter │ ├── If unvoiced: bypass/attenuate/mute │ └── Add to output with overlap │ ├── STEP 4: NORMALIZE │ └── Scale peak to 0.95 │ ├── STEP 5: VISUALIZATION (OPTIONAL) │ └── 5-panel display: original/filtered spectrograms, │ pitch/target plots, waveform comparison, │ legend/stats, time axis │ └── CLEANUP & OUTPUT └── Remove temp objects, select output, optionally play

Key Variables & Objects

VariableTypePurpose
originalIDObject IDOriginal Sound object
monoSourceSoundMono version for processing
pitchPitchSmoothed pitch contour
outputSoundSoundFiltered output
windowDurRealWindow duration (0.025-0.06 s)
hopDurRealHop size (50% of windowDur)
numFramesIntegerNumber of OLA frames
attenFactorRealLinear attenuation factor
currentPitchRealPitch at frame midpoint
isVoicedBooleanVoiced/unvoiced decision
targetFreqRealFilter center frequency
effectiveBWRealCalculated bandwidth
lowBound/highBoundRealFilter cutoff frequencies

Critical Processing Loop

FOR i FROM 1 TO numFrames // Timing frameStart = (i - 1) * hopDur frameEnd = frameStart + windowDur frameMid = (frameStart + frameEnd) / 2 // Pitch decision currentPitch = Get pitch at frameMid isVoiced = (currentPitch ≠ undefined AND currentPitch > 0) // Extract window frameSound = Extract part: frameStart, frameEnd, "Hanning" IF isVoiced // Calculate target targetFreq = currentPitch × f0_multiplier + f0_offset targetFreq = CLAMP(20, nyquist-100, targetFreq) // Calculate bandwidth IF bandwidth_mode = "Relative" effectiveBW = targetFreq × bandwidth_val ELSE effectiveBW = bandwidth_val ENDIF // Apply filter lowBound = targetFreq - effectiveBW/2 highBound = targetFreq + effectiveBW/2 filtered = Filter (pass Hann band): lowBound, highBound, rolloff_smoothness ELSE // Unvoiced handling IF unvoiced_mode = "Bypass" filtered = Copy: frameSound ELSIF unvoiced_mode = "Attenuate" filtered = Copy: frameSound Formula: "self × attenFactor" ELSE // Mute filtered = Copy: frameSound Formula: "0" ENDIF ENDIF // Overlap-add outputSound[frameStart:frameEnd] += filtered // Cleanup removeObject: frameSound, filtered END FOR

Visualization Components

Viewport Layout:
  • 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
Color Scheme:
  • 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:

  1. Select Noise Reduction preset
  2. Set minimum_pitch = 75 Hz, maximum_pitch = 300 Hz
  3. Set F0_multiplier = 1.0, F0_offset = 0
  4. Use Fixed bandwidth = 120 Hz
  5. Set unvoiced_mode = Attenuate, unvoiced_attenuation = -20 dB
  6. Quality = Standard
  7. 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:

  1. Select Custom preset
  2. Set F0_multiplier = 1.5 (perfect fifth ratio)
  3. Use Relative bandwidth = 0.25
  4. Set unvoiced_mode = Bypass
  5. Quality = High for musical quality
  6. 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:

  1. Select Fundamental Extraction preset
  2. Set minimum_pitch = 200 Hz, maximum_pitch = 1000 Hz (violin range)
  3. Set Relative bandwidth = 0.3
  4. Set unvoiced_mode = Attenuate (-12 dB)
  5. Quality = High for clean extraction
  6. 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:

  1. Process audio multiple times with different multipliers
  2. Run 1: multiplier = 1.0 (fundamental)
  3. Run 2: multiplier = 2.0 (octave)
  4. Run 3: multiplier = 1.5 (fifth)
  5. Crossfade between results over time
  6. Add reverb to blended output

Result: Evolving harmonic texture that moves between intervals while tracking pitch.