Latent Space Navigation β User Guide
Learns a latent space from event-level audio patches (on-the-fly autoencoder), then navigates that space to generate a new timeline by selecting/morphing events along a deterministic latent trajectory. The result sounds like traveling through hidden acoustic identities.
What this does
This script implements a Latent Space Navigation engine β an AI-powered tool that learns a latent space from event-level audio patches using an on-the-fly autoencoder, then navigates that space to generate a new timeline by selecting or morphing events along a deterministic latent trajectory. The result sounds like traveling through hidden acoustic identities.
π§ What is Latent Space Navigation?
This approach treats each audio event as a point in a learned low-dimensional space:
- Events are segmented from the source (200msβ3s)
- Autoencoder learns to compress each event into a latent vector (2β32 dimensions)
- Navigation generates a path through this latent space (ThermoDrift, Attractor, Convection, or 2D Mixer)
- Selection picks events nearest to the path; Morphing crossfades between them
- The result is a new timeline that "travels" through the discovered acoustic identities
Key Features:
- 6 Preset Strategies β Gentle Drift to Dense Mixer, plus Custom
- On-the-Fly Autoencoder β Pure numpy MLP with Adam, trained on log-mel patches
- 2 Navigation Modes β Trajectory (1D path) and Mixer (2D plane sweep)
- 3 Path Types β ThermoDrift (temperature-modulated), Attractor (pole-hopping), Convection (flow along axes)
- 2 Output Modes β Selector (nearest event) and Morph (weighted crossfade)
- 3 Duration Modes β Preserve, Expand, Compress
- Event Density Control β Set events per second in output
- LRU Event Selection β Least-recently-used penalty prevents repetition
- Comprehensive Visualization β 5-panel display with waveforms, spectrograms, navigation stats
Technical Implementation: (1) Event Segmentation: Praat segments audio using intensity peaks. (2) Mel Patches: Python extracts 40Γ32 log-mel patches per event. (3) Autoencoder: MLP with hidden layer, leaky ReLU, denoising, L2 reg, Adam. (4) Latent Encoding: Z = encode(patches). (5) Navigation: Generate path through latent space. (6) Reconstruction: Select/morph events, crossfade concatenation. (7) Stats & Visualization.
Quick start
- In Praat, select exactly one Sound object (any duration, any content).
- Run scriptβ¦ β select
latent_navigation.praat. - Choose Preset (2-7 for specific strategies, 1 for custom).
- Set autoencoder parameters (learning steps, latent size, seed).
- Choose navigation mode, path type, and adjust travel speed/dwell/smoothing.
- Select output mode (Selector/Morph) and target duration mode.
- Set event density (events per second).
- Enable Draw_visualization for analysis display.
- Click OK β engine segments, trains autoencoder, navigates, reconstructs.
Latent Navigation Theory
Autoencoder Architecture
Latent Temperature
Navigation Modes
LRU Event Selection
Output Modes
π― Selector Mode
At each step, pick the nearest event to the path point. Concatenate chosen events with equal-power crossfades.
Smoothing: for latent jumps > 0.5Γmax_dist, apply gentle fade-in to reduce abruptness.
π Morph Mode
For each step, crossfade between current event and next event, weighted by latent distance:
Duration Control
| Mode | Formula |
|---|---|
| Preserve | target_dur = original_duration |
| Expand | target_dur = original_duration Γ 1.5 |
| Compress | target_dur = original_duration Γ 0.6 |
Output event count = target_dur Γ density
Preset Strategies
Preset 2: Gentle Drift
π± Subtle Latent Travel
Learning: 80 steps, latent=6 | Nav: Trajectory/ThermoDrift
Speed: 0.3 | Dwell: 0.5 | Smooth: 0.5
Output: Selector | Density: 2.5 ev/s
Character: Gentle drift through latent space β subtle, smooth evolution
Use on: Ambient, pads, subtle variations
Preset 3: Deep Attractors
π§² Pole-Hopping
Learning: 150 steps, latent=12 | Nav: Trajectory/Attractor
Speed: 0.4 | Dwell: 0.7 | Smooth: 0.3
Output: Selector | Density: 3.0 ev/s
Character: Moves between attractor poles, dwelling at each β creates clear sections
Use on: Sectional forms, narrative structures
Preset 4: Convection Flow
π Rising/Sinking Flow
Learning: 120 steps, latent=10 | Nav: Trajectory/Convection
Speed: 0.6 | Dwell: 0.3 | Smooth: 0.4
Output: Selector | Density: 3.5 ev/s
Character: Flow along principal axis β hot events rise, cool sink β creates directional motion
Use on: Evolving textures, risers, builds
Preset 5: Fast Scatter
π¨ Rapid Dispersion
Learning: 100 steps, latent=8 | Nav: Trajectory/ThermoDrift
Speed: 1.2 | Dwell: 0.1 | Smooth: 0.2
Duration: Expand (1.5Γ) | Density: 5.0 ev/s
Character: Fast, scattered navigation β many events, rapid changes
Use on: Glitch, chaotic textures, fast variations
Preset 6: Slow Morph
π Crossfaded Transitions
Learning: 150 steps, latent=10 | Nav: Trajectory/Attractor
Speed: 0.3 | Dwell: 0.6 | Smooth: 0.8
Output: Morph | Density: 2.0 ev/s
Character: Slow morphing between events β smooth latent transitions
Use on: Ambient morphs, gradual transformations
Preset 7: Dense Mixer
ποΈ 2D Plane Sweep
Learning: 100 steps, latent=8 | Nav: Mixer
Speed: 0.5 | Dwell: 0.3 | Smooth: 0.5
Output: Selector | Density: 4.0 ev/s
Character: 2D spiral sweep through reduced latent space β dense, exploratory
Use on: Dense textures, exploration, complex material
Parameters & Controls
Autoencoder Parameters
| Parameter | Default | Description |
|---|---|---|
| Learning_steps | 100 | Training iterations (10β500) |
| Latent_size | 8 | Bottleneck dimensions (2β32) |
| Seed | 42 | For reproducibility |
Navigation Parameters
| Parameter | Default | Description |
|---|---|---|
| Navigation_mode | Trajectory | Trajectory (1D path) or Mixer (2D plane) |
| Path_type | ThermoDrift | ThermoDrift, Attractor, Convection (Trajectory mode) |
| Travel_speed | 0.5 | Speed of latent movement (0.1β2.0) |
| Dwell_amount | 0.3 | Time spent at attractor poles / dwell regions (0β1) |
| Smoothing | 0.4 | Fade strength for latent jumps / morph blending (0β1) |
Output Parameters
| Parameter | Default | Description |
|---|---|---|
| Output_mode | Selector | Selector (nearest event) or Morph (crossfade blend) |
| Target_duration | Preserve | Preserve, Expand (1.5Γ), Compress (0.6Γ) |
| Density_(events_per_s) | 3.0 | Events per second in output (0.5β20.0) |
| Draw_visualization | 1 | Generate 5-panel display |
| Play_result | 1 | Audition after processing |
Visualization & Analysis
5-Panel Display
Reading Navigation Stats
- Steps: Number of events in output timeline
- Unique events used: How many distinct source events were selected
- Repetition rate: (steps - unique)/steps β how often events repeat
- Avg latent travel: Average distance moved in latent space per step
- Mean temperature: Average of temperature field (0=cold, 1=hot)
- Most used events: IDs of the 3 most frequently selected events
Applications
Electroacoustic Composition
Use case: Creating new timelines that explore the latent structure of source material
Technique: Deep Attractors or Convection Flow presets
Workflow:
- Select a 20-60 second recording with varied texture
- Run with Deep Attractors preset
- Examine navigation stats to understand which events are most used
- Export and use as movement in larger work
Sound Design for Media
Use case: Creating evolving textures, transitions, risers
Technique: Slow Morph or Fast Scatter on appropriate sources
Applications:
- Risers: Convection Flow with Expand duration β rising energy
- Transitions: Gentle Drift β subtle evolution between scenes
- Textures: Dense Mixer β complex, layered exploration
Music Production
Use case: Creating variations, remixes, or generative parts
Technique: Different seeds and presets on same source
Examples:
- Drum loops: Fast Scatter creates rapid, glitchy variations
- Melodic phrases: Gentle Drift creates subtle melodic variations
- Pads: Slow Morph creates evolving harmonic textures
Research & Education
Use case: Studying autoencoder latent spaces, navigation strategies
Technique: Compare path types on same source, examine most-used events
Learning outcomes:
- Understand how latent space organizes acoustic events
- See how different navigation paths produce different outputs
- Explore relationship between temperature and event repetition
- Observe morph vs. selector output differences
Practical Workflow Examples
Troubleshooting Common Issues
Cause: Python not installed, or packages missing
Solution: Install Python and required packages: pip install numpy soundfile scipy
Cause: Source has few intensity peaks, or segmentation parameters inappropriate
Solution: Use source with more dynamic variation, or adjust min/max event duration in script
Cause: Too few steps, too small latent size, or data too complex
Solution: Increase learning_steps, increase latent_size, or use simpler source
Cause: Crossfade insufficient at splice points
Solution: Increase XFADE_SEC in Python script (currently 8ms)
Cause: Too few events for given density, or LRU penalty too low
Solution: Reduce density, or increase LRU penalty in Python
Advanced Techniques
In Python, modify _path_thermodrift(), _path_attractor(), or _path_convection() to implement new navigation strategies.
Modify hidden layer size calculation or add more layers for deeper networks.
Change temperature calculation in encode_events() to emphasize different acoustic properties.
The script preserves multichannel audio throughout β mel patches from mono mix, but reconstruction maintains original channels.