Neural Granular Texture Morpher — User Guide
AI-driven granular synthesis with unsupervised learning: analyzes audio textures, clusters similar sonic characteristics using K-Means, and generates evolving morphing textures that intelligently transition between discovered sonic categories.
What this does
This script implements a neural granular texture morpher that combines granular synthesis with unsupervised machine learning to analyze, categorize, and regenerate audio textures. Unlike traditional granular synthesis that uses random or sequential grain selection, this system employs K-Means clustering to discover natural sonic categories within your audio and creates intelligent morphing patterns that transition between these discovered textures.
Key Features:
- Unsupervised Learning – Automatic discovery of sonic textures using K-Means clustering
- Multi-Dimensional Analysis – 5 acoustic features: spectral centroid, bandwidth, pitch, harmonicity, intensity
- Intelligent Morphing – Smooth transitions between discovered texture clusters
- Robust Implementation – Manual K-Means algorithm with no external dependencies
- Memory-Efficient Processing – Block-based synthesis with safe object management
- Customizable Texture Control – Adjustable cluster count and morphing speed
- Professional Output – High-quality granular synthesis with peak normalization
Technical Implementation: (1) Granular Analysis: Divide audio into overlapping grains, extract 5 acoustic features per grain. (2) Feature Normalization: Apply Z-score standardization for balanced clustering. (3) K-Means Clustering: Implement manual Expectation-Maximization algorithm to group grains into texture clusters. (4) Morphing Synthesis: Generate output by cycling through clusters at controlled speed, randomly selecting grains from target clusters. (5) Robust Concatenation: Use table-based object management for memory-safe grain assembly. Key insight: The "neural" aspect comes from the unsupervised learning that discovers natural categories in your audio, enabling intelligent rather than random grain selection.
Quick start
- In Praat, select exactly one Sound object with interesting textures.
- Run script… →
neural_granular_morpher.praat. - Analysis Parameters:
- grain_size_ms – Duration of each analysis grain (default: 60ms)
- overlap_ratio – Overlap between consecutive grains (default: 0.5)
- max_frequency_hz – Maximum frequency for analysis (default: 8000Hz)
- number_of_clusters – Texture categories to discover (default: 4)
- Synthesis Parameters:
- output_duration_sec – Length of generated texture (default: 10.0s)
- morph_speed_hz – Speed of texture transitions (default: 0.5Hz)
- Enable play_result for immediate preview.
- Click OK – processing begins with progress updates in Info window.
- The script executes four phases:
- Feature Extraction – Analyzing grains and extracting acoustic features
- Neural Clustering – Learning texture categories (K-Means training)
- Generative Synthesis – Creating morphing texture output
- Final Assembly – Combining grains into final result
- Result appears as "originalname_TextureMorph" with peak normalization applied.
Analysis Phase
Granular Decomposition
🔬 Multi-Feature Acoustic Analysis
Grain extraction: Overlapping window analysis across entire sound
Feature set: 5 complementary acoustic descriptors
Normalization: Z-score standardization for balanced clustering
Output: Feature matrix for machine learning
Grain Calculation
Granular analysis parameters:
Acoustic Feature Extraction
Five-Dimensional Feature Space
| Feature | Description | Acoustic Property | Analysis Method |
|---|---|---|---|
| Spectral Centroid | Center of spectral mass | Brightness vs darkness | Spectrum centre of gravity |
| Spectral Bandwidth | Spread of spectral energy | Tone vs noise character | Spectrum standard deviation |
| Fundamental Frequency | Pitch (F0) in Hertz | Perceived pitch | Pitch analysis with cubic interpolation |
| Harmonicity | Harmonic-to-noise ratio | Tonality vs noisiness | Harmonicity (CC) method |
| Intensity | Acoustic intensity in dB | Loudness/amplitude | Intensity with 75Hz minimum |
Feature Extraction Implementation
Feature Normalization
Z-Score Standardization
Manual normalization implementation:
Neural Clustering Phase
K-Means Algorithm
🧠 Unsupervised Texture Discovery
Algorithm: Manual K-Means clustering with Expectation-Maximization
Process: Iteratively assign grains to clusters and update cluster centers
Convergence: Stops when assignments stabilize or max iterations reached
Output: Organized grain clusters representing distinct textures
K-Means Mathematics
Manual implementation details:
Cluster Organization
Texture Category Discovery
Post-clustering organization:
Cluster Interpretation
Understanding Discovered Textures
Cluster 1: Bright Tonal
- High spectral centroid (bright)
- Clear fundamental frequency (tonal)
- High harmonicity (clean tones)
- Examples: Bell-like sounds, vocal vowels
Cluster 2: Dark Noisy
- Low spectral centroid (dark)
- Weak or noisy pitch
- Low harmonicity (noisy)
- Examples: Breath sounds, noise bursts
Cluster 3: Mid-Range Complex
- Medium spectral centroid
- Complex spectral structure
- Mixed harmonic/noise content
- Examples: Consonants, textured instruments
Cluster 4: Loud Transients
- High intensity values
- Brief temporal features
- Various spectral characters
- Examples: Drum hits, percussive sounds
Synthesis Phase
Morphing Algorithm
🔄 Intelligent Texture Transition
Morph logic: Cyclic progression through cluster space
Grain selection: Random sampling from target clusters
Timing control: Precise morph speed in Hz
Memory management: Block-based processing for stability
Morphing Mathematics
Cluster progression algorithm:
Block-Based Assembly
Memory-Safe Grain Concatenation
Robust implementation strategy:
Morph Speed Effects
Controlling Texture Transition Rate
| Morph Speed | Cycle Time (4 clusters) | Musical Character | Best For |
|---|---|---|---|
| 0.1 Hz | 10 seconds | Very slow, evolving | Ambient, background textures |
| 0.25 Hz | 4 seconds | Slow, noticeable changes | Evolving pads, soundscapes |
| 0.5 Hz | 2 seconds | Moderate, musical | General texture morphing |
| 1.0 Hz | 1 second | Fast, rhythmic | Rhythmic patterns, pulses |
| 2.0 Hz | 0.5 seconds | Very fast, intense | Glitch effects, rapid changes |
Parameters
Analysis Parameters
| Parameter | Type | Range | Default | Description |
|---|---|---|---|---|
| grain_size_ms | positive | 20-200 ms | 60 ms | Duration of each analysis grain |
| overlap_ratio | positive | 0.1-0.9 | 0.5 | Overlap between consecutive grains |
| max_frequency_hz | positive | 4000-16000 Hz | 8000 Hz | Maximum frequency for spectral analysis |
| number_of_clusters | integer | 2-8 | 4 | Number of texture categories to discover |
Synthesis Parameters
| Parameter | Type | Range | Default | Description |
|---|---|---|---|---|
| output_duration_sec | positive | 1.0-60.0 s | 10.0 s | Duration of generated texture output |
| morph_speed_hz | positive | 0.1-5.0 Hz | 0.5 Hz | Speed of texture transitions |
| play_result | boolean | 0/1 | 1 | Auto-play after processing |
Parameter Effects Guide
20-40 ms: Very short, granular texture
40-80 ms: Standard granular character
80-120 ms: Smoother, more tonal results
120-200 ms: Almost micro-sampling character
overlap_ratio Effects:
0.1-0.3: Sparse, separated grains
0.3-0.5: Moderate overlap, some grain identity
0.5-0.7: Smooth transitions, less graininess
0.7-0.9: Very smooth, almost continuous
number_of_clusters Effects:
2 clusters: Simple binary texture alternation
3-4 clusters: Clear texture categories
5-6 clusters: Complex, detailed texture mapping
7-8 clusters: Very detailed, potentially chaotic
morph_speed_hz Effects:
0.1-0.3 Hz: Very slow, evolving changes
0.3-0.7 Hz: Musical, noticeable transitions
0.7-1.5 Hz: Fast, rhythmic texture changes
1.5-5.0 Hz: Very fast, intense morphing
Applications
Sound Design & Textures
Use case: Creating evolving soundscapes and complex textures from simple sources
Technique: Use environmental recordings with moderate cluster counts
Examples: Evolving pads, atmospheric beds, synthetic environments
Vocal Processing
Use case: Transforming vocal recordings into textured vocal beds
Technique: Process vocal phrases with 4-6 clusters for articulation variety
Results: Evolving vocal textures, ghost choir effects, articulated pads
Instrumental Transformation
Use case: Creating new instrumental textures from acoustic recordings
Technique: Use instrumental phrases with varied playing techniques
Applications: Textural orchestration, synthetic instrument creation
Rhythmic Textures
Use case: Generating complex rhythmic patterns from percussive material
Technique: Fast morph speeds with percussive source material
Results: Evolving rhythmic patterns, complex groove textures
Practical Workflow Examples
🌊 Ocean Texture Evolution
Goal: Create evolving ocean-like textures from water recordings
Settings:
- grain_size_ms: 80 (smooth water character)
- overlap_ratio: 0.6 (smooth transitions)
- clusters: 4 (wave types, splashes, etc.)
- morph_speed: 0.3 Hz (slow, natural evolution)
- output_duration: 30.0 s (long texture bed)
Result: Continuously evolving ocean texture that cycles through different water sound characteristics naturally.
🎤 Vocal Texture Bed
Goal: Transform spoken word into evolving vocal texture
Settings:
- grain_size_ms: 50 (capture phoneme transitions)
- overlap_ratio: 0.5 (balanced grain identity)
- clusters: 5 (vowels, consonants, breaths, etc.)
- morph_speed: 0.4 Hz (musical transition rate)
- output_duration: 15.0 s (usable texture length)
Result: Evolving vocal texture that intelligently cycles through different speech articulations and qualities.
🥁 Rhythmic Texture Generator
Goal: Create complex rhythmic patterns from drum loops
Settings:
- grain_size_ms: 40 (percussive character)
- overlap_ratio: 0.4 (clear grain separation)
- clusters: 3 (kicks, snares, cymbals)
- morph_speed: 1.2 Hz (rhythmic pattern rate)
- output_duration: 8.0 s (loop-friendly length)
Result: Rhythmic texture that cycles through different drum sound categories creating complex, evolving patterns.
Advanced Techniques
- Extreme clustering: Use 7-8 clusters with very textured sources for maximum complexity
- Micro-granular: 20-30ms grains with high overlap for granular cloud effects
- Macro-textures: 150-200ms grains with low overlap for almost sampling-like results
- Rhythmic morphing: Match morph speed to musical tempo for rhythmic synchronization
Experiment with source material that has clear categorical differences for the most interesting results
- Best sources: Environmental recordings, vocal phrases, instrumental performances with varied articulation
- Good sources: Complex synthetic sounds, textured noise sources, field recordings
- Challenging sources: Very uniform material, single sustained tones, simple waveforms
- Experimental sources: Multi-layered mixes, processed sounds, granular textures
Troubleshooting Common Issues
Cause: Source too uniform, too few clusters, analysis parameters inappropriate
Solution: Use more varied source material, increase cluster count, adjust grain size
Cause: Long source material, many clusters, small grain size
Solution: Use shorter source selections, reduce cluster count, increase grain size
Cause: Too many clusters, fast morph speed, inappropriate source
Solution: Reduce cluster count, slow morph speed, use more coherent source material
Cause: Very long output duration, many grains, system memory limits
Solution: Reduce output duration, increase grain size, close other applications