Spectral Feature-Driven Vibrato — User Guide

Intelligent adaptive modulation: analyzes spectral characteristics of audio to automatically generate customized vibrato parameters—flatness controls depth, roughness controls rate—creating perfectly tailored pitch modulation for each unique sound.

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 an intelligent, adaptive vibrato effect that analyzes the spectral characteristics of input audio and automatically generates customized vibrato parameters. By measuring two key spectral features—spectral flatness (noise-to-tonal ratio) and spectral roughness (inharmonicity)—the system determines optimal vibrato depth and rate for each specific sound. The result is vibrato that feels naturally suited to the source material, with noisy sounds receiving subtle modulation and tonal sounds receiving more pronounced, musical vibrato.

Key Features:

Why spectral feature-driven vibrato? Traditional vibrato effects use fixed parameters that may not suit all sounds. This adaptive approach recognizes that different sounds benefit from different types of modulation: pure tones can handle deep, slow vibrato without becoming muddy, while noisy or complex sounds need subtler, faster modulation to avoid unpleasant artifacts. By analyzing the audio's spectral character, the system applies vibrato that enhances rather than obscures the source material.

Technical Implementation: (1) Source preservation: Creates working copy to protect original. (2) Spectral analysis: Converts to spectrum and analyzes 80-5000 Hz range. (3) Feature extraction: Calculates spectral flatness (tonal vs noise character) and roughness (inharmonicity). (4) Parameter mapping: Converts features to vibrato depth (0.05-0.20 semitones) and rate (4-7 Hz). (5) Vibrato application: Uses delay-line pitch shifting with smooth interpolation. (6) Feedback: Displays analysis results and applied parameters.

Quick start

  1. In Praat, select exactly one Sound object (any material).
  2. Run script…spectral_feature_vibrato.praat.
  3. The script automatically:
    • Creates a safety copy of your sound
    • Analyzes spectral characteristics
    • Calculates optimal vibrato parameters
    • Applies customized vibrato to the copy
  4. Check the Info window for analysis results:
    • Spectral Flatness and Roughness values
    • Calculated vibrato depth and rate
    • Processing confirmation
  5. The modified sound automatically plays and is selected.
  6. Your original sound is preserved unchanged.
Quick tip: Try different types of sounds to see how the vibrato adapts. Pure tones and vocal sustains will receive deeper, slower vibrato. Noisy sounds and consonants will get subtler, faster modulation. Complex musical passages receive balanced parameters. The analysis focuses on the 80-5000 Hz range where vibrato is most perceptually relevant. Check the Info window to understand why particular parameters were chosen for your sound.
Important: This is an adaptive effect—parameters change based on input. Very short sounds (<0.5 seconds) may not provide enough data for accurate analysis. Extremely noisy material may receive very subtle vibrato that's hard to hear. The script preserves your original but creates multiple temporary objects during processing. Stereo files are processed correctly but analyzed as mono for feature extraction. Processing time increases with file length due to spectral analysis.

Spectral Analysis Theory

The Adaptive Vibrato Concept

Why One Size Doesn't Fit All

Different sounds require different vibrato characteristics:

PURE TONES (sine waves, flute, whistle): - Can handle deep, slow vibrato (0.15-0.20 semitones, 4-5 Hz) - Deep modulation enhances musical expression - Slow rate feels natural and lyrical COMPLEX TONES (voice, strings, most instruments): - Need moderate parameters (0.08-0.15 semitones, 5-6 Hz) - Balanced modulation adds warmth without muddiness - Medium rate provides natural vibrato character NOISY SOUNDS (consonants, noise, unpitched percussion): - Require subtle, fast vibrato (0.05-0.08 semitones, 6-7 Hz) - Deep modulation would create unpleasant artifacts - Fast rate provides subtle enhancement without obvious pitch change The script automatically detects these categories through spectral analysis

🔍 Spectral Analysis Range

The script analyzes frequencies between 80 Hz and 5000 Hz because:

  • Below 80 Hz: Often rumble, not musically relevant for vibrato
  • Above 5000 Hz: Harmonic structure less important for vibrato perception
  • 80-5000 Hz: Covers fundamental frequencies and most important harmonics where vibrato has maximum perceptual impact

This focused analysis provides cleaner, more relevant feature measurements.

Digital Signal Processing Foundation

Spectrum Analysis in Praat

The script uses Praat's built-in spectrum analysis:

SPECTRUM CREATION: To Spectrum (converts time-domain to frequency-domain) SPECTRUM PROPERTIES: nBins = Get number of bins (frequency resolution) binWidth = Get bin width (Hz per bin) ANALYSIS LOOP: FOR each frequency bin from 80 Hz to 5000 Hz: amp = Get real value in bin (amplitude at that frequency) power = amp² (power for flatness calculation) Calculate local roughness (difference from neighbors) This provides the raw data for feature extraction

Why Power Spectrum?

Amplitude vs Power spectrum:

Amplitude spectrum: Shows voltage levels
Power spectrum: Shows energy (amplitude squared)

Why use power?
- Better represents perceptual loudness
- More robust for mathematical operations
- Standard for acoustic feature extraction
- Reduces effect of phase relationships

The script uses power spectrum for both flatness and roughness calculations

Spectral Features

Spectral Flatness

📊 Tonal vs Noise Character

Definition: Ratio of geometric mean to arithmetic mean of power spectrum

MATHEMATICAL DEFINITION: Flatness = (Π powerᵢ)^(1/n) / (Σ powerᵢ / n) Where: powerᵢ = power in i-th frequency bin n = number of bins in analysis range COMPUTATIONAL IMPLEMENTATION: Using logarithms for numerical stability: lnSum = Σ ln(powerᵢ) linearSum = Σ powerᵢ Flatness = exp(lnSum/n) / (linearSum/n)

Interpretation of values:

  • 0.0: Perfectly tonal (single frequency)
  • 0.0-0.3: Very tonal (voices, instruments)
  • 0.3-0.7: Mixed character (typical speech/music)
  • 0.7-1.0: Very noisy (consonants, noise)
  • 1.0: Perfect white noise

Spectral Roughness

Inharmonicity and Spectral Variation

Definition: Average absolute difference between each frequency bin and its local neighbors

MATHEMATICAL DEFINITION: Roughness = Σ |ampᵢ - (ampᵢ₋₁ + ampᵢ₊₁)/2| / n Where: ampᵢ = amplitude in i-th frequency bin n = number of valid roughness calculations This measures how "jagged" the spectrum is: - Smooth spectrum → low roughness (pure tones) - Jagged spectrum → high roughness (noise, inharmonic sounds) The calculation excludes first and last bins to avoid edge effects

Roughness Interpretation

Roughness values and sound character:

0.000-0.005: Very smooth (sine waves, some vowels)
0.005-0.015: Smooth (most musical tones, clean vocals)
0.015-0.030: Moderate (typical speech, complex tones)
0.030-0.050: Rough (consonants, noisy sounds)
0.050+: Very rough (unpitched percussion, noise)

Note: Actual values depend on amplitude scaling—the script uses relative measurements within the adaptive mapping

Feature Correlation

How Flatness and Roughness Relate

Typical feature combinations:

Low Flatness + Low Roughness:
Pure tones, whistles, sine waves → Deep, slow vibrato

Low Flatness + High Roughness:
Inharmonic tones, bells, metallic sounds → Medium parameters

High Flatness + Low Roughness:
Filtered noise, some consonants → Subtle, fast vibrato

High Flatness + High Roughness:
Noise, unpitched sounds → Very subtle modulation

The script uses both features for robust parameter determination

Parameter Mapping

🎛️ From Analysis to Musical Parameters

Vibrato Depth Mapping (0.05-0.20 semitones)

Depth = 0.05 + (Flatness × 0.15) Why this mapping? - Flatness measures tonal vs noise character - Noisy sounds (high flatness) need subtle modulation - Tonal sounds (low flatness) can handle deeper vibrato - 0.05 semitones minimum prevents inaudible effect - 0.20 semitones maximum avoids excessive pitch variation Example mappings: Flatness 0.1 (very tonal) → Depth 0.065 semitones Flatness 0.5 (mixed) → Depth 0.125 semitones Flatness 0.9 (very noisy) → Depth 0.185 semitones

Vibrato Rate Mapping (4-7 Hz)

Roughness_scaled = min(Roughness × 150, 1) Rate = 4 + (Roughness_scaled × 3) Why this mapping? - Roughness measures spectral complexity - Complex sounds need faster modulation to avoid muddiness - Pure sounds work well with slower, more lyrical rates - 4 Hz minimum for natural vibrato character - 7 Hz maximum to avoid "nervous" sounding modulation The ×150 scaling factor normalizes typical roughness values The min(..., 1) ensures values stay within 0-1 range

Mapping Rationale

Perceptual Considerations

Why these specific ranges work well:

DEPTH RANGE (0.05-0.20 semitones): 0.05 semitones: Very subtle, barely perceptible 0.10 semitones: Noticeable but conservative 0.15 semitones: Typical musical vibrato 0.20 semitones: Strong, dramatic vibrato RATE RANGE (4-7 Hz): 4 Hz: Slow, lyrical (typical for strings) 5 Hz: Medium, natural (typical for voice) 6 Hz: Faster, more energetic 7 Hz: Fast, intense (special effects) These ranges cover natural vibrato while avoiding extremes that might sound artificial or unpleasant

Musical Context Adaptation

How mapping suits different musical roles:

Lead melodies (tonal):
Low flatness → Deeper depth (0.06-0.12)
Medium roughness → Medium rate (5-6 Hz)
Result: Expressive, singing quality

Background pads (mixed):
Medium flatness → Medium depth (0.10-0.15)
Variable roughness → Adaptive rate
Result: Supportive without distraction

Percussive elements (noisy):
High flatness → Subtle depth (0.05-0.08)
High roughness → Faster rate (6-7 Hz)
Result: Subtle enhancement without pitch confusion

The adaptive approach works across diverse musical material

Delay-Line Vibrato Implementation

Smooth Pitch Shifting

The vibrato uses delay-line modulation with sample interpolation:

VIBRATO FORMULA: output = input[max(1, min(ncol, col + round(delay_samples)))] Where: delay_samples = base × (1 + depth × sin(2π × rate × t)) Parameters: base = 5.0 ms × sampling_rate / 1000 (samples) depth = calculated depth parameter rate = calculated rate in Hz t = time in seconds The max(1, min(ncol, ...)) ensures sample indices stay within bounds The rounding provides sample-accurate delay changes

Why Delay-Line Vibrato?

Advantages of delay-line approach:

Computational efficiency: Single formula evaluation
High quality: Uses original samples (no resynthesis artifacts)
Natural sound: Creates authentic pitch modulation
Preserves timing: No time-stretching side effects

Compared to other methods:
Phase vocoder: More computational, potential artifacts
Resampling: Can affect duration and quality
Delay-line: Clean, efficient, natural-sounding

The 5 ms base delay provides good pitch variation range

Processing Workflow

🔄 Step-by-Step Processing Pipeline

STEP 1: Source Verification and Preparation

Check: selected("Sound") exists Original sound: preserved unchanged Create: safety copy for processing Purpose: Non-destructive workflow

STEP 2: Spectral Analysis

Convert: Sound to Spectrum Analyze: 80-5000 Hz frequency range Calculate: Spectral flatness and roughness Display: Feature values in Info window

STEP 3: Parameter Mapping

Map: Flatness → Vibrato depth (0.05-0.20 semitones) Map: Roughness → Vibrato rate (4-7 Hz) Display: Calculated parameters in Info window

STEP 4: Vibrato Application

Apply: Delay-line vibrato to safety copy Use: max(1, min(ncol, ...)) for bounds protection Rename: Processed sound with "final_vibrato_" prefix

STEP 5: Completion and Feedback

Select: Final vibrato sound for user Play: Processed result automatically Display: Completion confirmation in Info window Preserve: Original sound remains available

Info Window Output

Understanding the Analysis Feedback

Typical Info window output:

=== STEP 1: Sound selected ===
Original sound: my_vocal_sustain

=== STEP 2: Copy created ===
Copy name: copy_of_my_vocal_sustain

=== STEP 3: Spectral Analysis ===
Spectral Flatness: 0.124567
Spectral Roughness: 0.008342

=== Scaled Vibrato Parameters ===
Vibrato Depth: 0.069 semitones
Vibrato Rate: 5.25 Hz

=== STEP 4: Applying Smooth Vibrato to Copy ===
Smooth vibrato applied successfully!
Final sound: final_vibrato_my_vocal_sustain

=== COMPLETE ===
Original sound preserved: my_vocal_sustain
Vibrato-modified sound ready: final_vibrato_my_vocal_sustain

This provides complete transparency about the processing

Object Management

Clean and Efficient Processing

The script carefully manages Praat objects:

OBJECT LIFECYCLE: 1. Original Sound: preserved throughout 2. Copy Sound: created for processing, becomes final output 3. Spectrum: created for analysis, removed after use 4. Final Sound: renamed copy with vibrato applied MEMORY MANAGEMENT: - Temporary objects (Spectrum) are explicitly removed - Only essential objects remain in Objects window - Original is always preserved and available - Clear naming prevents confusion USER EXPERIENCE: - Final vibrato sound is selected and played - Original remains available for comparison - Info window provides complete processing history

Applications

Vocal Processing

Use case: Adding natural-sounding vibrato to sustained vocals

Technique: Let the script analyze and adapt to each vocal character

Benefits:

Result: Vocals with authentic, context-appropriate vibrato

Instrument Enhancement

Use case: Adding vibrato to sampled or synthetic instruments

Technique: Process individual notes or phrases

Instrument-specific results:

Result: Instruments with naturally enhanced expression

Sound Design

Use case: Adding organic motion to synthetic sounds

Technique: Process synthesized tones and textures

Creative applications:

Result: More organic, living synthetic sounds

Educational and Research Use

Use case: Studying vibrato perception and parameter choices

Technique: Analyze diverse sounds and observe parameter choices

Learning opportunities:

Value: Practical insight into adaptive audio processing

Practical Workflow Examples

🎤 Lead Vocal Enhancement

Goal: Add expressive vibrato to vocal sustain

Process:

  • Select sustained vowel section
  • Run script - typically gets depth 0.06-0.10, rate 5-6 Hz
  • Compare original and processed
  • Use Info window to understand parameter choice

Result: Naturally enhanced vocal with appropriate vibrato

🎻 String Section Sweetening

Goal: Add warmth to string samples

Process:

  • Select string section or individual notes
  • Run script - typically gets depth 0.08-0.12, rate 4-5 Hz
  • Blend with original to control intensity
  • Process different instruments separately

Result: Warmer, more expressive string sounds

🔊 Synthetic Texture Animation

Goal: Add organic motion to synth pads

Process:

  • Select static synth tone or pad
  • Run script - parameters vary with synth character
  • Experiment with different synth sounds
  • Layer multiple processed versions

Result: More living, evolving synthetic textures

Advanced Techniques

Selective processing:
  • Process only sustained sections of audio
  • Use different analysis windows for different sound types
  • Combine with manual parameter tweaking when needed
  • Create vibrato automation by processing short segments
Comparative analysis:
  • Process similar sounds from different sources
  • Compare parameter choices across sound categories
  • Build intuition about spectral feature relationships
  • Develop personal mappings based on preferred results

Troubleshooting Common Issues

Problem: Vibrato too subtle to hear
Cause: Very noisy source material, very short sound
Solution: Try more tonal source material, longer audio segments
Problem: Artifacts or distortion in output
Cause: Extreme spectral characteristics, very brief sounds
Solution: Use sounds longer than 0.5 seconds, avoid extreme noise
Problem: No analysis results in Info window
Cause: No sound selected, Praat environment issue
Solution: Ensure sound is selected, check Praat version
Problem: Processing very slow for long files
Cause: Spectral analysis computational load
Solution: Process shorter segments, use faster computer

Technical Deep Dive

Algorithm Optimization

Efficient Spectral Analysis

The script uses optimized analysis techniques:

NUMERICAL STABILITY: Uses logarithms for geometric mean calculation: geometric_mean = exp(Σ ln(powerᵢ) / n) Prevents numerical underflow with very small power values FREQUENCY RANGE OPTIMIZATION: Analyzes only 80-5000 Hz range Reduces computation by excluding irrelevant frequencies Focuses on perceptually important range for vibrato BOUNDARY PROTECTION: Uses max(1, min(ncol, ...)) in vibrato formula Prevents array index errors Ensures robust operation with all input types

Computational Complexity

Processing time breakdown:

Spectral analysis: O(n) where n = number of frequency bins
Feature calculation: O(n) for flatness and roughness
Vibrato application: O(m) where m = number of samples

Typical performance:
1-second sound: 0.5-2 seconds total processing
10-second sound: 3-10 seconds total processing
60-second sound: 20-60 seconds total processing

Bottleneck: Spectral analysis for long files
Optimization: The 80-5000 Hz range reduces n significantly

Psychoacoustic Foundations

Why These Features Work

Perceptual research basis: The relationship between spectral characteristics and optimal modulation parameters is supported by psychoacoustic research. Tonal sounds with clear pitch benefit from slower, deeper modulation that enhances pitch perception. Noisy sounds with diffuse spectral energy require faster, subtler modulation to avoid creating pitch confusion or unpleasant artifacts. The specific ranges used (0.05-0.20 semitones, 4-7 Hz) align with natural vibrato observed in skilled vocal and instrumental performance across musical traditions.

Cross-Cultural Vibrato Patterns

Natural vibrato across musical traditions:

Western classical singing:
Depth: 0.5-1.0 semitones, Rate: 5-7 Hz

Western string instruments:
Depth: 0.2-0.5 semitones, Rate: 5-6 Hz

Indian classical music:
Depth: 0.1-0.3 semitones, Rate: 4-6 Hz (andolan)

Middle Eastern music:
Depth: 0.2-0.8 semitones, Rate: 4-7 Hz (tahrir)

The script's ranges accommodate diverse musical expressions while avoiding extremes

Future Extensions

Potential Algorithm Enhancements

Possible improvements and extensions:

Dynamic analysis: Track features over time for evolving vibrato
Multi-band processing: Different parameters for different frequency ranges
Context awareness: Consider musical context and role
User preference learning: Adapt mapping based on user feedback
Real-time implementation: Adaptive vibrato in live performance

Research applications:
- Study of optimal vibrato parameters
- Cross-cultural vibrato comparison
- Perceptual validation of adaptive approach
- Development of more sophisticated feature sets