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.
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.
Key Features:
- 2 Input Sources — SDIF/SPEAR text files OR selected Praat Sound (NumPy peak-picking)
- Interactive trajectory display — colour-coded partials by amplitude, click to select tracks
- Per-track editing — mute, gain (±60 dB), frequency scaling (0.25×–4×)
- 11 Presets — Faithful, OctaveUp, OctaveDown, GlassBells, HollowClarinet, FrozenDrone, SlowMotion, Reversed, DarkPad, Shimmer, Inharmonic, LowBand
- Resynthesis controls — max partials/frame, transpose ratio, inharmonicity, frequency shift, brightness tilt, gate, band low/high, harmonic selection (All/Odd/Even)
- 3 Phase modes — Praat-compatible (frame-reset), SDIF phase, Track-continuous
- Audition preview — fast render of first 12 seconds with current settings
- Render to Praat — full resynthesis imported back as a Sound object
Quick start
- In Praat, select at most one Sound object (optional — the GUI can also open SDIF/SPEAR files).
- Run script… →
SPEAR_Fast_Resynthesis.praat. - A Python GUI window opens. If you selected a Sound, it will be analysed automatically; otherwise, click Open SDIF / SPEAR… to load a file.
- In the trajectory view, click a partial track to select it. Use the track editor (bottom-left) to mute, adjust gain, or scale frequency.
- Choose a preset from the dropdown, or adjust individual controls in the Spectral Transform and Time / Phase sections.
- Click ▶ Audition to preview the first 12 seconds with current settings.
- Click ▶ Render to Praat — the full resynthesis is rendered, imported into Praat as a Sound object, and the GUI closes.
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.
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)
| Preset | Transpose | Inharm | Brightness | Gate | Band High | Harmonic | Stretch | Reverse | Freeze | Character |
|---|---|---|---|---|---|---|---|---|---|---|
| Faithful | 1.0 | 1.0 | 0.0 | 0.0 | 20000 | All | 1.0 | no | 0 | Clean resynthesis |
| OctaveUp | 2.0 | 1.0 | 0.0 | 0.0 | 20000 | All | 1.0 | no | 0 | Up one octave |
| OctaveDown | 0.5 | 1.0 | 0.0 | 0.0 | 20000 | All | 1.0 | no | 0 | Down one octave |
| GlassBells | 1.0 | 1.3 | 0.4 | 0.0 | 20000 | All | 1.0 | no | 0 | Bell-like inharmonic |
| HollowClarinet | 1.0 | 1.0 | 0.0 | 0.01 | 20000 | Odd | 1.0 | no | 0 | Odd harmonics only |
| FrozenDrone | 1.0 | 1.0 | 0.0 | 0.0 | 20000 | All | 2.0 | no | mid | Frozen middle frame |
| SlowMotion | 1.0 | 1.0 | 0.0 | 0.0 | 20000 | All | 3.0 | no | 0 | 3× time stretch |
| Reversed | 1.0 | 1.0 | 0.0 | 0.0 | 20000 | All | 1.5 | yes | 0 | Reverse + stretch |
Key parameters
- 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)
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.
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.
• 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
- 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).