Phase Magnet — Phase-Aware Sound Hybridisation
Weaves two sounds together by alternating between them at phase-compatible splice points. A "magnetism" parameter keeps the cursors proportionally aligned, producing click-free hybrids from glitch stutter to ambient morph.
What this does
This script implements phase-aware sound hybridisation — it weaves two sounds together by alternating between them at splice points chosen for phase compatibility. A "magnetism" parameter keeps the playback cursors proportionally aligned (like magnetic tape pulling the sounds together), while crossfades and zero-crossing detection ensure click-free transitions. The result ranges from glitchy stutter (fast alternation, short segments) to smooth ambient morphs (long segments, high magnetism).
Key Features:
- 5 Presets — Glitch Stutter, Ambient Morph, Rhythmic Alternation, Chaotic Scatter, Custom
- 3 Splice Modes — Zero crossing, Same-slope zero crossing, Nearest amplitude match
- Magnetism parameter — 0–100%, controls how strongly splice points stay proportionally aligned
- Randomness — Adds variation to splice position (0–100%)
- Crossfade blending — Cosine fades at every splice (0–150 ms)
- Alternation modes — Strict A-B-A-B or probabilistic (dice roll per segment)
- Performance optimised — v1.7 uses native Praat zero-crossing lookup (O(1) per splice)
- Visualisation — 8×8 canvas with source waveforms, hybrid output, and splice timeline (blue = A, orange = B)
Get value at sample number inside loops over the entire patience window (up to millions of command calls). For zero-crossing modes, the search is now a single Get nearest zero crossing call — thousands of reads reduced to one command. Mode 3 (amplitude match) still scans, but the window is bounded (≤ 100 ms) so it cannot blow up on large patience settings.
Quick start
- In Praat, select exactly two Sound objects (order matters: A = first selected, B = second).
- Run script… →
Phase_Magnet.praat. - Choose a preset from the dropdown (Glitch Stutter, Ambient Morph, Rhythmic Alternation, Chaotic Scatter, or Custom).
- Adjust parameters: Crossfade length, Patience, Magnetism, Segment range (min/max), Splice mode, Randomness, Start source, Alternation mode.
- Click OK — script weaves the sounds, creates output
PhaseMagnet_NameA_NameB.
5 Presets
| Preset | Crossfade | Patience | Magnetism | Segment (ms) | Matching | Random | Alt Mode | Character |
|---|---|---|---|---|---|---|---|---|
| Glitch Stutter | 2 ms | 20 ms | 95% | 10–45 | Zero crossing | 50% | Strict | Fast, glitchy, stuttering texture |
| Ambient Morph | 150 ms | 500 ms | 60% | 400–1200 | Same-slope ZC | 10% | Probabilistic | Smooth, evolving, ambient morphs |
| Rhythmic Alternation | 5 ms | 50 ms | 100% | 125–250 | Same-slope ZC | 0% | Strict | Steady A-B-A-B, rhythmic |
| Chaotic Scatter | 15 ms | 300 ms | 20% | 20–800 | Amplitude match | 100% | Probabilistic | Unpredictable, wild, chaotic |
Splice Modes (3)
Mode 1 — Zero crossing
Finds the nearest zero crossing to the predicted splice position. Guarantees amplitude continuity (sample value = 0 at the splice point). Fastest mode — O(1) using Praat's native Get nearest zero crossing.
Best for: Percussion, transients, or any sound where click-free splicing is critical.
Mode 2 — Same-slope zero crossing
Same as zero crossing, but also requires the slope (direction) of the crossing to match the source's slope. This preserves waveform phase (positive vs negative zero crossing).
Best for: Sustained tones, where matching slope reduces phase cancellation at the splice.
Mode 3 — Nearest amplitude match
Searches for a sample whose amplitude is closest to the source's endpoint amplitude, with bonus for matching slope. Performs a bounded linear scan (≤100 ms window).
Best for: Noisy or complex signals where zero crossings are too frequent or amplitude continuity is more important.
Score function (Mode 3)
score = |v₀ - from_amp| + slope_penalty + 0.5 × d
where d = normalised distance from target position, slope_penalty = 0 if slopes match, else 0.2.
The candidate with lowest score is chosen as the splice point.
Parameters
Timing & Geometry
| Parameter | Range | Default | Description |
|---|---|---|---|
| Crossfade_length_ms | 0–200 | 10 | Cosine fade duration at each splice. Prevents clicks. |
| Patience_ms | 0–1000 | 100 | Search window around predicted splice point (±). Larger = more compatible matches. |
| Magnetism (%) | 0–100 | 80 | 0 = ignore proportional alignment (free drift). 100 = lock to proportionally aligned position. |
| Minimum_segment_ms | > crossfade | 50 | Shortest possible segment length. |
| Maximum_segment_ms | > min | 500 | Longest possible segment length. Actual length randomised between min and max. |
Behaviour
| Parameter | Options | Description |
|---|---|---|
| Matching_mode | Zero crossing / Same-slope ZC / Nearest amplitude match | How splice points are chosen in the target sound. |
| Randomness (%) | 0–100 | Adds random offset to predicted splice position. 100 = up to ±patience samples of jitter. |
| Start_source | A / B | Which sound provides the first segment. |
| Alternation_mode | Strict A-B-A-B / Probabilistic | Strict = alternates every segment. Probabilistic = dice roll per segment (probability = segment length relative to range). |
predicted = magnetism × (proportional_position) + (1 - magnetism) × (previous_position)where proportional_position = (current_time / dur_A) × dur_B (or the inverse). Magnetism = 100% means splice points stay proportionally aligned (sounds play in sync). Magnetism = 0% means splice points drift freely from the previous position.
Applications
Glitch / Stutter effects (Glitch Stutter preset)
Use case: Transform a vocal or drum loop into a stuttering, glitchy texture.
Settings: Very short segments (10–45 ms), high magnetism (95%), zero-crossing mode, high randomness (50%). The rapid alternation between sounds creates a granular, stuttering effect.
Ambient morphs / crossfades (Ambient Morph preset)
Use case: Gradually morph from one sound into another over time.
Settings: Long segments (400–1200 ms), long crossfade (150 ms), moderate magnetism (60%), same-slope ZC mode. The result is smooth, evolving hybrids where the two sounds blend seamlessly.
Rhythmic alternation (Rhythmic Alternation preset)
Use case: Create a call-and-response pattern between two sounds.
Settings: Strict A-B-A-B alternation, magnetism = 100% (perfect sync), medium segment length (125–250 ms). Each sound plays for a fixed rhythmic duration before switching.
Chaotic / unpredictable textures (Chaotic Scatter preset)
Use case: Experimental sound design where unpredictability is desired.
Settings: Low magnetism (20%), high randomness (100%), amplitude match mode, probabilistic alternation. The splice points are nearly random, producing wild, disorienting hybrids.
Workflow: Voice + Drone → Ambient Vocal Morph
Sounds: A = spoken voice, B = sustained synth drone.
Settings: Ambient Morph preset (long segments, same-slope ZC, magnetism=60%).
Result: The voice and drone weave together — voice phrases fade into the drone, then drift back. The magnetism keeps approximate timing alignment, so voice syllables still land roughly where expected.
Workflow: Drum loop + Drum loop → Rhythmic Stutter
Sounds: Two different drum loops at same tempo.
Settings: Rhythmic Alternation preset (strict A-B-A-B, magnetism=100%, segment = 1/8 note).
Result: A new drum pattern that alternates between the two loops every 1/8 note — like a live remix.
Workflow: Speech + Noise → Chaotic Glitch
Sounds: A = speech, B = white noise.
Settings: Chaotic Scatter preset (low magnetism, high randomness, amplitude match mode).
Result: The speech is constantly interrupted by noise bursts at unpredictable positions — a chaotic, glitchy texture.
• Clicks at splices: Increase crossfade_length_ms (10–50 ms usually sufficient). Ensure crossfade ≤ segment length.
• Output duration too long/short: The total duration is approximately the sum of both input durations (up to n_A + n_B samples). For shorter outputs, reduce segment lengths or stop manually.
• Magnetism not working as expected: Magnetism = 100% locks to proportional alignment based on time, not sample count. If sounds have different durations, proportional alignment maps progress (0→1) from one sound to the other.
• Visualisation shows wrong splice colours: Blue = A (first selected sound), orange = B (second). Check selection order in Praat before running.
• Mode 3 (amplitude match) is slow: The window is bounded to 100 ms to prevent explosion. If you need larger search, use zero-crossing modes (fast, O(1)).
Visualisation (Suite 8×8)
- Title bar — preset name, sound names, magnetism %, splice mode, splice count
- Source A waveform (left) — blue curve, first selected sound
- Source B waveform (right) — orange curve, second selected sound
- Hybridised output waveform — full-width, dark grey
- Splice-source timeline — full-width, colour-coded bars: blue = from A, orange = from B. Each bar's width = segment duration.
- Summary bar — segment counts (A/B), crossfade length, segment range, output duration