Spectral Pitch Shifter — User Guide

Intelligent pitch modulation: analyzes spectral characteristics in real-time to drive dynamic pitch shifting that adapts to audio content.

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 implements spectral-driven pitch shifting — an intelligent approach to pitch modulation that analyzes audio spectral characteristics in real-time and uses them to control pitch shifting parameters. Unlike static pitch effects, this system adapts to the audio content, creating dynamic pitch variations that respond to spectral flatness and roughness measurements. The process involves multi-window spectral analysis, feature extraction, and content-aware pitch modulation.

Key Features:

What is spectral-driven pitch shifting? Traditional pitch shifting: fixed parameters regardless of audio content. Spectral-driven shifting: analyzes audio characteristics and adapts pitch modulation accordingly. Advantages: (1) Context sensitivity: Different effects for vocals, instruments, noise. (2) Musical intelligence: Preserves musical relationships while adding variation. (3) Dynamic evolution: Parameters change throughout the audio. (4) Feature extraction: Uses meaningful audio descriptors. (5) Adaptive behavior: Responds to changes in audio content. Use cases: Intelligent vocal processing, adaptive sound design, experimental music, audio research, content-aware effects.

Quick start

  1. Select Sound object in Praat
  2. Run spectral_pitch_shifter.praat
  3. Script automatically analyzes spectral content at 8 time points
  4. View analysis results in Info window
  5. Script applies adaptive pitch shifting based on spectral features
  6. Result named "spectral_pitch_shift_originalname" is created and played
Automatic Analysis: The script analyzes your audio automatically — no parameters to configure. It detects spectral characteristics and applies appropriate pitch shifting. Check the Info window to see the analysis results and understand how your audio was processed.
Processing Time: Spectral analysis is computationally intensive. Longer audio files will take more time to process. The script provides progress updates in the Info window.

Spectral Analysis Theory

Multi-Window Analysis System

🔍 8-Point Temporal Analysis

Analysis strategy: Distributed time windows across audio duration

Analysis points: 8 windows evenly distributed across duration Window size: 200ms (100ms before + 100ms after analysis point) Frequency range: 80-5000 Hz (focus on perceptually relevant range) Overlap: Windows may overlap for continuous coverage For each analysis point: 1. Extract 200ms window around time point 2. Apply Hamming window for spectral analysis 3. Convert to frequency spectrum 4. Calculate spectral features 5. Store features for pitch shifting control

Benefits: Captures spectral evolution over time while maintaining computational efficiency

Spectral Feature Extraction

📊 Spectral Flatness

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

Calculation: flatness = (geometric_mean(power)) / (arithmetic_mean(power)) Where: geometric_mean = exp(mean(ln(power))) arithmetic_mean = mean(power) Interpretation: flatness ≈ 1: White noise (equal energy across frequencies) flatness ≈ 0: Pure tone (energy concentrated at one frequency) Typical range: 0.1-0.8 for most audio Pitch shifting application: High flatness (noisy) → More extreme pitch shifts Low flatness (tonal) → Subtler pitch shifts

⚡ Spectral Roughness

Definition: Measure of spectral complexity and irregularity

Calculation: roughness = mean(|amplitude[i] - (amplitude[i-1] + amplitude[i+1])/2|) Interpretation: High roughness: Complex, inharmonic spectra (consonants, noise) Low roughness: Smooth, harmonic spectra (vowels, sustained tones) Pitch shifting application: High roughness → Faster pitch modulation Low roughness → Slower, smoother pitch changes

Parameter Mapping

Spectral FeatureRangePitch ParameterEffect
Flatness0.1-0.8Shift Depth2-8 semitones
Roughness0.01-0.1Modulation Speed0.5-3.5 Hz
Time Position0%-100%Feature InterpolationSmooth transitions

Pitch Shifting Algorithm

Real-time Parameter Adaptation

For each pitch point (10ms intervals): STEP 1: Locate current analysis segment Find which two analysis windows bracket current time Calculate interpolation progress between them STEP 2: Interpolate spectral features currentFlatness = flatness[segment] + progress * (flatness[segment+1] - flatness[segment]) currentRoughness = roughness[segment] + progress * (roughness[segment+1] - roughness[segment]) STEP 3: Calculate shifting parameters shiftDepth = 2 + (currentFlatness * 6) # 2-8 semitones modulationSpeed = 0.5 + (currentRoughness * 3.0) # 0.5-3.5 Hz STEP 4: Apply pitch modulation phaseDelta = 2 * π * modulationSpeed * timeDelta currentPhase = currentPhase + phaseDelta semitoneShift = shiftDepth * sin(currentPhase) freqMultiplier = 2^(semitoneShift / 12) newFreq = originalFreq * freqMultiplier

Content-Aware Behavior Examples

🎤 Vocal Content

Typical features: Low flatness (tonal), moderate roughness

Resulting shift: Subtle depth (2-4 semitones), medium speed (1-2 Hz)

Effect: Natural-sounding pitch variation that preserves vocal quality

🎵 Instrumental Content

Typical features: Medium flatness, low-moderate roughness

Resulting shift: Moderate depth (3-6 semitones), smooth speed (0.5-1.5 Hz)

Effect: Musical pitch modulation that enhances instrumental character

🌊 Noisy/Textural Content

Typical features: High flatness, high roughness

Resulting shift: Extreme depth (6-8 semitones), fast speed (2-3.5 Hz)

Effect: Dramatic pitch variations that complement noisy character

Technical Implementation

Processing Pipeline:
  1. Original Sound Analysis: Extract pitch contour using Praat's Manipulation object
  2. Spectral Analysis: 8 windows with FFT spectrum calculation
  3. Feature Extraction: Flatness and roughness computation
  4. Pitch Tier Construction: Create new pitch contour with spectral-driven shifts
  5. Resynthesis: Apply new pitch contour using overlap-add synthesis
  6. Output: Create and play final processed sound

Applications

Intelligent Vocal Processing

Adaptive Pitch Effects: The script automatically applies different pitch shifting characteristics to different parts of vocal performances — subtle variations during sustained vowels, more dramatic effects during consonants and transitions.
Content Preservation: Unlike static pitch effects, spectral-driven shifting maintains the natural character of vocals while adding expressive variation that complements the original content.

Sound Design and Music Production

Instrument Processing: Apply to instrumental recordings to create dynamic pitch effects that respond to the instrument's spectral characteristics — different behavior for strings, winds, percussion, etc.
Textural Evolution: The time-varying nature of the effect creates evolving pitch landscapes that change throughout the audio, ideal for atmospheric and textural sound design.

Research and Analysis

Spectral Feature Study: Use the analysis results in the Info window to study how spectral characteristics correlate with perceptual qualities in different types of audio.
Adaptive Algorithm Development: The script demonstrates a framework for content-aware audio processing that can be extended to other effects and applications.

Technical Considerations

Analysis Limitations: The 8-window analysis provides a good balance between accuracy and speed, but very rapidly changing audio may not be captured perfectly. The interpolation between windows ensures smooth transitions.
Pitch Detection: The script relies on Praat's pitch detection algorithm. Very noisy or polyphonic content may produce unreliable pitch contours, affecting the final result.
Parameter Ranges: The script uses carefully tuned parameter mappings that work well for most audio content. The ranges (2-8 semitones depth, 0.5-3.5 Hz speed) provide noticeable but musical effects across different sound types.