SPEAR Fast Resynthesis — Interactive Partial Editor

Interactive SPEAR-like editor for sinusoidal partial tracks. Load SDIF/SPEAR files or analyse a selected Praat Sound, visualise partial trajectories, edit individual tracks (mute, gain, frequency scaling), and resynthesise with full control over partial selection, transposition, inharmonicity, brightness, and time manipulation.

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

What this does

This script implements a fast, interactive SPEAR-like sinusoidal resynthesis editor. It loads spectral analysis data from SDIF files or SPEAR text exports, or analyses a selected Praat Sound via NumPy peak-picking. The GUI displays partial trajectories (frequency vs time, colour-coded by amplitude), allows per-track editing (mute, gain, frequency scaling), and provides extensive resynthesis controls: transposition, inharmonicity, brightness tilt, band filtering, harmonic selection, time stretch, reverse, and phase modes.

What is SPEAR? SPEAR (Sinusoidal Partial Editing Analysis and Resynthesis) is a classic application for sinusoidal modelling, developed by Michael Klingbeil. It analyses audio into time-varying partials (frequency, amplitude, phase) and allows editing them before resynthesis. This script is a modern, fast, Python-based alternative that runs entirely in a GUI, with real-time auditioning, and integrates with Praat for source audio selection and result import.

Key Features:

Performance: The engine uses vectorised NumPy operations and a frame-by-frame partial-bank renderer. A 60-second source with 100 frames resynthesises in under 5 seconds on a modern CPU. The GUI uses Tkinter with a dark theme and runs entirely in Python — no external dependencies beyond NumPy and Tkinter.

Quick start

  1. In Praat, select at most one Sound object (optional — the GUI can also open SDIF/SPEAR files).
  2. Run script…SPEAR_Fast_Resynthesis.praat.
  3. A Python GUI window opens. If you selected a Sound, it will be analysed automatically; otherwise, click Open SDIF / SPEAR… to load a file.
  4. In the trajectory view, click a partial track to select it. Use the track editor (bottom-left) to mute, adjust gain, or scale frequency.
  5. Choose a preset from the dropdown, or adjust individual controls in the Spectral Transform and Time / Phase sections.
  6. Click ▶ Audition to preview the first 12 seconds with current settings.
  7. Click ▶ Render to Praat — the full resynthesis is rendered, imported into Praat as a Sound object, and the GUI closes.
Quick tip: Use Open SDIF / SPEAR… to load existing sinusoidal analysis files from SPEAR or other SDIF exporters. Use Use Praat Sound to analyse the selected sound directly from Praat — this is the fastest way to get started with resynthesis. The FrozenDrone preset freezes the middle frame for a sustained drone effect. Enable Track-continuous phase mode for coherent phase across frames.
Important: The GUI requires Python with Tkinter and NumPy. If the script fails to launch, ensure these are installed (pip install numpy; Tkinter is usually included with Python). The Praat script auto-detects Python on macOS, Windows, and Linux. The analysis mode uses NumPy's FFT-based peak-picking — it is not as sophisticated as SPEAR's analysis but is sufficient for creative resynthesis. The rendered WAV is 16-bit mono, peak-normalised to the output peak level (default 0.95).

GUI Overview

Left panel — Trajectory view

  • Partial trajectories: Frequency (Hz, log scale) vs time (s). Each partial is a continuous line.
  • Colour coding: Amplitude mapped to a heat map (blue = quiet, red = loud).
  • Click a track: Selects it for editing (track editor appears in the bottom-left panel).
  • Track slider: Controls how many of the loudest tracks are shown (40–300).

Right panel — Controls

  • Preset / Output: Preset dropdown, output sample rate, output peak.
  • Spectral Transform: Max partials, amplitude scale, transpose, inharmonicity, frequency shift, brightness, gate, band limits, harmonic selection.
  • Time / Phase: Time stretch, reverse, freeze frame, phase mode.
  • Praat Sound analysis: Hop size, max frequency, peak threshold for re-analysis.

Track editor (bottom-left)

  • Mute: Silences the selected track.
  • Gain dB: –60 to +24 dB adjustment.
  • Freq ×: 0.25× to 4× frequency scaling (pitch shift per track).
  • Reset track: Clears edits for the selected track.
  • Reset ALL track edits: Clears all per-track edits.

Bottom bar

  • Status: Shows current action, load time, render progress.
  • Progress bar: Indicates render progress.
  • ▶ Audition: Renders and plays first 12 seconds.
  • ■ Stop: Stops playback.
  • Cancel: Closes the GUI without rendering to Praat.
  • ▶ Render to Praat: Full render, imports into Praat.
State persistence: The GUI saves its state (last source file, parameters, sample rate) to spear_fast_state.json in the Praat preferences folder. It restores these settings on the next launch, so you don't have to re-enter your favourite settings.

Controls & Presets

Presets (11)

PresetTransposeInharmBrightnessGateBand HighHarmonicStretchReverseFreezeCharacter
Faithful1.01.00.00.020000All1.0no0Clean resynthesis
OctaveUp2.01.00.00.020000All1.0no0Up one octave
OctaveDown0.51.00.00.020000All1.0no0Down one octave
GlassBells1.01.30.40.020000All1.0no0Bell-like inharmonic
HollowClarinet1.01.00.00.0120000Odd1.0no0Odd harmonics only
FrozenDrone1.01.00.00.020000All2.0nomidFrozen middle frame
SlowMotion1.01.00.00.020000All3.0no03× time stretch
Reversed1.01.00.00.020000All1.5yes0Reverse + stretch

Key parameters

Transposition chain:
  • Transpose ratio: f' = f × trans (octave shift: 2.0 = +12 st, 0.5 = −12 st)
  • Inharmonicity: f' = 1000 × (f/1000)^β (β > 1 = stretched, β < 1 = compressed)
  • Frequency shift: f' = f + shift_Hz (constant offset)
  • Brightness tilt: amp' = amp × (f'/1000)^tilt (negative = dark, positive = bright)
Selection: Only the max_partials loudest partials per frame are retained. Harmonic selection (All/Odd/Even) filters partial indices.

Phase Modes — Coherence vs. Artifact

Praat-compatible (default)

Resets each partial's phase every frame (phase = 0 at each frame start). This creates measurable interference between overlapping Hann windows — sidebands appear at multiples of the frame rate around every partial. This is a deliberate artefact that gives the output its characteristic edge and "bite."

Use: When you want the classic SPEAR/phase-vocoder-like texture with sideband richness.

Track-continuous

Maintains phase coherence across frames: phase[t+1] = phase[t] + 2π·freq·hop. This produces a cleaner, thinner sound without the frame-rate sidebands.

Use: When you want a purer, more transparent resynthesis, especially for sustained tones.

SDIF phase

Uses the phase values stored in the SDIF/SPEAR file (if available). If not present, falls back to Praat-compatible mode.

Use: When the analysis file contains reliable phase information and you want to preserve it.

Phase mode default (v0.7.2): The default is Praat-compatible — the interference artefacts are measurably an artefact (97% envelope ripple at 440 Hz, 153% at 1050 Hz), but it is the sound this instrument has always had. The coherent alternative (Track-continuous) was judged thinner and plainer. Both modes remain selectable; nothing about the rendering maths changed, only which mode is selected on startup.

Applications

SPEAR file editing and resynthesis

Use case: Open a SPEAR text export or SDIF file, edit individual tracks (mute unwanted partials, adjust gain, pitch-shift selected tracks), and resynthesise with creative transformations.

Settings: Load a .txt or .sdif file, select tracks in the trajectory view, adjust parameters, render to Praat.

Praat Sound analysis → resynthesis

Use case: Select a Sound in Praat, run the script — the GUI analyses it with NumPy peak-picking, then you can apply all resynthesis controls and render back to Praat.

Settings: Select a Sound in Praat before running the script. Use the analysis controls (hop, max freq, peak threshold) to tune the peak-picking.

Track-level editing for sound design

Use case: Isolate specific partials (e.g., a noisy track or a resonant peak) and manipulate them independently — mute unwanted partials, boost others, or pitch-shift individual tracks.

Settings: Load a file, click tracks in the trajectory view, use the track editor to mute, gain, or frequency-scale selected tracks.

Creative resynthesis presets

Use case: Quickly apply familiar transformations: octave shift, bell-like inharmonicity, odd-only harmonics, frozen drone, reverse, etc.

Settings: Choose a preset from the dropdown. Each preset sets all relevant parameters for a specific character.

Workflow: Voice → GlassBells resynthesis

Source: Singing voice analysed via Praat Sound or loaded from SPEAR.
Settings: GlassBells preset (inharmonicity=1.3, brightness=0.4).
Result: The voice becomes bell-like — inharmonic partials create a shimmering, metallic timbre.

Workflow: Instrumental track → Frozen drone

Source: Instrumental recording.
Settings: FrozenDrone preset (time_stretch=2.0, freeze_frame=mid).
Result: The instrument is stretched and frozen on the middle frame — a sustained drone.

Workflow: Spear file → Hollow clarinet

Source: SPEAR text export of a clarinet recording.
Settings: HollowClarinet preset (gate=0.01, harmonic=Odd).
Result: Only odd harmonics are retained, creating a clarinet-like timbre from any input.

Troubleshooting:
GUI doesn't open / Python not found: Ensure Python is installed and on your PATH. The script auto-detects common locations on macOS (/opt/homebrew/bin/python3, /usr/local/bin/python3) and falls back to "python3" / "python".
NumPy or Tkinter missing: Install with pip install numpy. Tkinter is usually included; on Linux, install python3-tk.
Analysis of Praat Sound is slow: Increase hop size (0.02–0.04 s) or reduce max frequency. The NumPy peak-picking is fast but uses FFT per frame; large files may take a few seconds.
Audition preview is silent: Check that sounddevice is installed (pip install sounddevice) or use the Render to Praat button to hear the full result.
Phase mode sounds different from older SPEAR: The default "Praat-compatible" mode reproduces the original SPEAR Fast behaviour. "Track-continuous" is cleaner but thinner — switch modes to taste.
Partial trajectories are sparse: Increase the "tracks" slider (bottom of trajectory view) to show more partials. The view shows the loudest N tracks.

Visualisation

The GUI's trajectory view displays:
  • X axis: Time in seconds (0 to file duration).
  • Y axis: Frequency in Hz (log scale, 20 Hz to max freq).
  • Colour: Amplitude mapped to a heat map — blue (quiet) to red (loud).
  • Selected track: Highlighted in white.
  • Track count: Shows how many of the loudest tracks are displayed (adjustable).
Click any trajectory to select it for editing. The track editor appears below the trajectory view.