Doppler Effect Simulator — User Guide

Real‑time pitch‑shift simulation of moving sound sources based on acoustic physics. Implements Doppler pitch shift and distance‑based amplitude cues for realistic spatial audio effects.

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

What this does

This script simulates the Doppler effect — the change in frequency (and amplitude) of a sound as its source moves relative to a listener. It applies time‑varying pitch‑shifting based on the radial velocity of the source, and optionally a distance‑based amplitude attenuation for enhanced realism. The simulation is physically accurate, using the standard acoustic Doppler formula and inverse‑square‑law amplitude scaling.

Key Features:

What is the Doppler effect? When a sound source moves toward a listener, the sound waves are compressed, raising the perceived pitch. When it moves away, the waves are stretched, lowering the pitch. The amount of shift depends on the radial component of the source’s velocity. This script calculates that shift for every moment of the sound, applies it via PSOLA, and optionally adjusts the amplitude to simulate decreasing volume with distance.

Technical Implementation: (1) Pitch analysis: Extract a Pitch object from the original sound. (2) Physics loop: For each time step, compute the source’s radial velocity relative to the listener, then compute the Doppler factor f' = f * c / (c + v_radial). (3) Pitch‑tier construction: Build a PitchTier that holds the time‑varying shift factors. (4) PSOLA resynthesis: Apply the PitchTier to a Manipulation object and resynthesize the shifted sound. (5) Amplitude scaling: Optionally apply a gain curve gain = d / sqrt(d² + v²(t − t_c)²) to simulate distance attenuation. (6) Visualization: Draw the source path, pitch‑shift factor over time, and gain curve.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…Doppler_Effect_Simulator.praat.
  3. Choose a Preset (Fast Car, Jet Flyover, etc.) or select “Custom” to enter your own values.
  4. Adjust Speed (m/s), Closest distance (m), and Time at closest (s) if using Custom.
  5. Check Apply amplitude cue to add distance‑based volume changes.
  6. Enable Visualize to see the motion, pitch‑shift, and gain curves.
  7. Click OK – the processed sound will be created as “originalname_Doppler”.
Quick tip: Start with a preset – Fast Car gives a clear, familiar Doppler shift. Enable Visualize to understand how the source motion relates to the pitch curve. For voice or instrument sounds, keep Closest distance above 2 m to avoid extreme volume changes. Use Sci‑Fi Warp for exaggerated, dramatic effects (supersonic speeds).
Important: The script modifies pitch and amplitude based on physical laws. Very high speeds (>300 m/s) or very close distances (<0.5 m) can produce extreme shifts that may sound artificial or cause clipping. The pitch‑shifting uses PSOLA, which works best on monophonic, harmonic sounds (voice, solo instruments). Polyphonic or noisy material may produce artifacts. Always listen to the result and adjust parameters if needed.

Physics & Implementation

Doppler Shift Formula

Perceived frequency: f' = f · c / (c + v_radial) Where: f = original frequency (Hz) f' = perceived frequency (Hz) c = speed of sound in air (343 m/s) v_radial = radial component of source velocity (m/s) (positive when source moves away, negative when approaching)

Radial Velocity Calculation

Source position at time t: x = v · (t − t_c) Distance to listener: r = √(d² + x²) Radial velocity: v_radial = v · (x / r) Where: v = source speed (m/s) t_c = time at closest approach (s) d = closest distance (m) x = horizontal displacement from closest point

Amplitude Distance Cue

Gain factor (inverse‑square law approximation): gain = d / r Where: d = closest distance (m) r = current distance (m) The amplitude of the sound is multiplied by this factor at each sample, simulating the decrease in volume as the source moves farther away.

Processing Pipeline

1. INPUT VALIDATION - Ensure exactly one Sound is selected. - Read its duration, sampling frequency. 2. USER FORM & PRESETS - Show form with presets and custom parameters. - Apply preset values if selected. 3. PHYSICS ENGINE a) Pitch analysis → Pitch object. b) For each time step: - Compute radial velocity. - Compute Doppler factor. - Add point to PitchTier. c) PSOLA resynthesis with the PitchTier. d) Optional amplitude scaling using gain formula. 4. VISUALIZATION (if enabled) - Draw source path. - Plot pitch‑shift factor over time. - Plot gain curve. 5. CLEANUP & OUTPUT - Remove temporary objects. - Rename output sound. - Play result if requested.

Presets & Parameters

Built‑in Presets

PresetSpeed (m/s)Closest distance (m)Description
Fast Car (City Street)15.04.0Car passing at ~50 km/h, typical street distance
Jet Flyover (High Altitude)250.0100.0Subsonic jet at high altitude, distant rumble
Ambulance Passing (Close)20.02.0Emergency vehicle passing nearby, strong shift
Slow Bicycle5.01.0Gentle, slow pass‑by, subtle effect
Sci‑Fi Warp (Extreme)340.00.5Supersonic, extremely close, dramatic pitch sweep

Custom Parameters

ParameterDefaultRangeDescription
Speed_m_s25.00.1 – 500Speed of the source in meters/second
Closest_distance_m5.00.1 – 200Closest distance between source and listener (meters)
Time_at_closest_s0.50 – durationTime in the sound when the source is closest (seconds)
Apply_amplitude_cueon/offEnable distance‑based volume attenuation
Normalize_outputon/offNormalize output peak to 0.99 (prevents clipping)
Visualizeon/offShow motion, pitch‑shift, and gain plots
Playon/offPlay the result after processing
Min_pitch_Hz7550 – 200Minimum pitch for analysis (Hz)
Max_pitch_Hz600200 – 2000Maximum pitch for analysis (Hz)
Parameter tips:
  • Speed: Everyday speeds are 5–30 m/s (18–108 km/h). Use 100+ m/s for aircraft, 340+ m/s for supersonic effects.
  • Closest distance: 1–5 m for close pass‑by, 10–100 m for distant sources.
  • Time at closest: Usually set to the middle of the sound for symmetric shift. Moving it earlier or later makes the effect asymmetric.
  • Amplitude cue: Turn off for pure pitch‑shift experiments; turn on for realistic spatial simulation.

Visualization

When Visualize is enabled, the script draws a three‑panel figure showing the motion, pitch shift, and amplitude gain.

Panel 1: Spatial Schematic

Top panel – source path relative to listener
• A horizontal line represents the source’s trajectory.
• A circle marks the listener’s position.
• Three colored circles show the source at start, closest point, and end.
• A dashed line indicates the closest‑approach distance.
• An arrow shows the direction of motion.

Panel 2: Pitch‑Shift Factor

Middle panel – pitch multiplication factor over time
• The y‑axis shows the factor by which the original pitch is multiplied.
• A dashed line at 1.0 represents no shift.
• Values >1 indicate pitch rise (approaching), values <1 indicate pitch drop (receding).
• The curve is blue and smooth, computed from the Doppler formula.

Panel 3: Amplitude Gain

Bottom panel – volume gain factor over time
• The y‑axis shows the gain factor (0 = silence, 1 = original volume at closest distance).
• The curve is red, showing how volume increases as the source approaches and decreases as it recedes.
• The peak is exactly at the time of closest approach.
Reading the graphs: The pitch‑shift curve is symmetric if the closest approach is at the middle of the sound. The gain curve is always symmetric (inverse‑square law). The spatial schematic helps visualize why the pitch rises, then falls – the radial velocity changes sign as the source passes the listener.

Applications

Sound Design for Film & Games

Use case: Creating realistic vehicle pass‑bys, flying objects, sci‑fi effects.

Technique: Apply Doppler preset to engine, rotor, or whoosh sounds.

Example: Use “Jet Flyover” on a jet engine sample for a distant aircraft flyover.

Acoustic Education & Demonstration

Use case: Teaching the Doppler effect in physics or audio courses.

Technique: Let students adjust speed and distance, hear the change, and see the curves.

Workflow:

Experimental Music & Composition

Use case: Generating dynamic pitch‑shifts for melodic or textural variation.

Technique: Use extreme settings (“Sci‑Fi Warp”) on vocal or instrument phrases.

Example: Apply a slow, close pass‑by to a piano note to create a “bending” effect.

Audio Forensics & Analysis

Use case: Simulating vehicle motions for comparison with real recordings.

Advantages:

Practical Workflow Examples

🚗 Realistic Car Pass‑By (Film SFX)

Goal: Convincing car passing on a street.

Settings:

  • Preset: Fast Car
  • Amplitude cue: ON
  • Visualize: ON
  • Normalize: ON

Result: Pitch rises as car approaches, peaks at closest point, falls as it recedes; volume follows inverse‑square law.

✈️ Distant Aircraft Flyover (Game Audio)

Goal: Distant jet rumble with subtle Doppler shift.

Settings:

  • Preset: Jet Flyover
  • Amplitude cue: ON
  • Closest distance: 150 m (increase for more distance)
  • Normalize: ON

Result: Gentle pitch shift with slow volume change, suitable for background ambiance.

🔬 Physics Classroom Demo

Goal: Clear demonstration of Doppler shift on a pure tone.

Settings:

  • Sound: 1 kHz sine wave, 5 seconds
  • Preset: Custom
  • Speed: 30 m/s
  • Closest distance: 3 m
  • Amplitude cue: OFF (to isolate pitch effect)
  • Visualize: ON

Result: Clean pitch sweep, easy to hear and see the relationship between motion and frequency shift.

Troubleshooting

Problem: Output sounds choppy or artifact‑ridden
Cause: PSOLA pitch‑shifting struggles with noisy or polyphonic material.
Solution: Use monophonic, harmonic sounds (voice, flute, violin). Avoid drums, noise, or full mixes.
Problem: No audible pitch shift
Cause: Speed too low, distance too large, or source speed parallel to listener.
Solution: Increase speed, decrease closest distance, ensure the source moves directly toward/away from listener (radial velocity > 0).
Problem: Extreme clipping/distortion
Cause: Amplitude cue combined with very close distance leads to huge gain near closest approach.
Solution: Increase closest distance, turn off amplitude cue, or enable normalization.
Problem: Visualization not appearing
Cause: “Visualize” checkbox unchecked, or Praat Picture window not available.
Solution: Check the Visualize option, ensure Praat Picture window is open.
Problem: Script complains about no selected sound
Cause: No sound selected, or more than one sound selected.
Solution: Select exactly one Sound object before running the script.

Performance Notes

Processing time depends on the length of the sound and the chosen time step (default 0.01 s). Longer sounds and smaller time steps increase computation. PSOLA resynthesis is the most expensive step. For real‑time or batch processing, consider reducing the time step or using shorter audio segments.