Rhythmic Fractal Granulator: Fractal Timing Granular Synthesis

A Praat script that generates self-similar rhythmic patterns using fractal mathematics, creating intricate granular textures from any audio source.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.0 (2025) Concept: Fractal rhythms + granular synthesis Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

The Rhythmic Fractal Granulator combines two powerful audio processing techniques: granular synthesis (using tiny audio grains) and fractal mathematics (creating self-similar patterns). The result is complex, evolving textures with inherent rhythmic structure that feels both organic and mathematical.

🎡 Core Concept: Fractal Rhythm Generation

Instead of random or regular timing, this script creates grain positions using a fractal algorithm:

  1. Start with a single grain at time 0
  2. For each generation: Add new grains at half-intervals between existing grains
  3. Mirror the pattern around a central pivot point
  4. Result: Self-similar rhythmic structure with nested patterns

Key Innovation: The fractal timing creates rhythms that are complex yet perceptually coherent. Our brains recognize the self-similar structure, making the result more musical than random granular clouds.

Quick Start

  1. In Praat, select exactly one Sound object as source material.
  2. Open the script editor and load Rhythmic_Fractal_Granulator.praat.
  3. Choose a Preset based on desired texture:
    • Dense Texture: Many short grains, cloud-like
    • Sparse Rhythmic: Fewer long grains, rhythmic
    • Glitchy: Very short grains, stuttering effect
    • Ambient Cloud: Medium grains, evolving texture
    • Percussive: Short grains, rhythmic emphasis
  4. Adjust parameters if desired (see guide below).
  5. Enable Draw_visualization to see fractal pattern.
  6. Click Run β†’ Run (or Ctrl+R).
  7. Listen to the generated fractal texture.
Source Material Tips:
  • Best sources: Sustained sounds (pads, drones, vocals)
  • Good results: Percussive sounds (for rhythmic effects)
  • Avoid: Very short sounds (<0.5s) unless using Sequential mode
  • Experiment: Speech, instruments, field recordings, noise
Processing Notes:
  • Output duration: Independent of source length
  • Channel preservation: Mono stays mono, stereo conversion optional
  • Memory usage: Scales with number of grains
  • Random seed: Different each run (for Random Read mode)
  • Unique ID: Each output gets random 5-digit identifier

Fractal Rhythm Theory

The Fractal Generation Algorithm

πŸŽ›οΈ Generation by Halving Intervals

INITIALIZATION: Generation 0: Single event at t = 0.1 seconds FOR EACH GENERATION g from 1 to GENERATIONS: shift = half_duration / (2^g) FOR EACH existing event at time parent_t: new_t = parent_t + shift + randomUniform(-jitter, jitter) IF new_t ≀ half_duration: ADD new event (generation = g) ENDIF ENDFOR ENDFOR WHERE: half_duration = (total_duration / 2) - center_buffer jitter = 0.005 seconds (small timing variation) center_buffer = 0.05 seconds (gap at center)

Example progression (simplified, no jitter):

  • Gen 0: Event at 0.1s
  • Gen 1: Add at 0.1 + shift₁ = ~1.0s
  • Gen 2: Add at 0.1 + shiftβ‚‚, 1.0 + shiftβ‚‚ = ~0.55s, ~1.45s
  • Gen 3: Add at four more positions
  • ... etc., creating binary tree structure

Symmetric Mirroring

πŸ”„ Creating Temporal Symmetry

Mirroring process:

AFTER generating left half (0 to pivot_time): FOR EACH event at time t_left with generation g: t_right = total_duration - t_left ADD mirrored event at t_right (same generation g) ENDFOR

Visualization: Creates perfect temporal symmetry around the pivot point.

Why symmetry?

  • Musical balance: Creates ABA' form naturally
  • Perceptual closure: Feels complete, not arbitrary
  • Structural clarity: Easier to follow than asymmetric patterns
  • Mathematical elegance: Maintains fractal property through mirroring

Amplitude Decay by Generation

FOR EACH grain from generation g: amplitude_factor = 1.0 * (1 - amp_decay)^g WHERE: amp_decay = 0.15 (15% reduction per generation) g = generation number (0 = parent, higher = later) EFFECT: Parent grains (gen 0): 100% amplitude First children (gen 1): 85% amplitude Second children (gen 2): 72.25% amplitude Third children (gen 3): 61.41% amplitude ... etc., exponential decay

Perceptual effect: Earlier/larger structures dominate, later/finer details provide texture. Creates hierarchical amplitude structure matching rhythmic hierarchy.

Granular Synthesis Basics

What are Audio Grains?

Definition: Short segments of audio (typically 10-200 ms) extracted from a source and processed independently.

In this implementation:

  • Grain duration: User-defined (default: 100 ms)
  • Extraction: Direct from source without pitch shifting
  • Envelopes: Applied to prevent clicks
  • Concatenation: Grains placed at fractal-determined times with silence between

Window (Envelope) Shapes

πŸ”” Bell Shape (Hanning Window)

Applied via: sin(Ο€ * n/(N-1))Β² WHERE: n = sample index (0 to N-1) N = total samples in grain CHARACTERISTICS: - Smooth fade in and out - No flat portion - Natural-sounding, cloud-like - Good for sustained sources

πŸ”οΈ Plateau Shape (Trapezoid)

Applied via: Praat's Fade in/Fade out PARAMETERS: fade_dur = 0.2 * grain_duration flat_dur = 0.6 * grain_duration CHARACTERISTICS: - Quick fade in/out (20% each side) - Long flat middle (60%) - Percussive, articulated - Good for rhythmic material

Source Reading Modes

ModeAlgorithmEffectBest For
Random OffsetEach grain starts at random position in sourceTexture cloud, non-linearSustained sounds, ambient
Sequential ScanGrains progress linearly through sourceMelodic development, narrativeSpeech, melodies, recordings

Preset Configurations

Preset 1: Dense Texture

☁️ Cloud-Like Texture

ParameterValueEffect
Total duration6.0 sMedium length texture
Grain duration0.05 s (50 ms)Short grains = dense texture
Generations6Many grains = high density
Window shapeBell (Hanning)Smooth, cloud-like
Read modeRandom OffsetNon-linear texture

Result: Dense, evolving granular cloud. Good for pads→textures.

Preset 2: Sparse Rhythmic

πŸ₯ Clear Rhythmic Structure

ParameterValueEffect
Total duration8.0 sLonger for rhythmic development
Grain duration0.2 s (200 ms)Long grains = clear attacks
Generations3Few grains = sparse pattern
Window shapePlateauPercussive, articulated
Read modeSequential ScanMelodic progression

Result: Clear rhythmic pattern with melodic development. Good for percussive sources.

Preset 3: Glitchy

⚑ Stuttering Glitch Effects

ParameterValueEffect
Total duration3.0 sShort, intense
Grain duration0.02 s (20 ms)Very short = stuttering
Generations7Many generations = complex
Window shapeBell (Hanning)Smooth despite short grains
Read modeRandom OffsetMaximum fragmentation

Result: Intense glitch/stutter effect. Good for vocal snippets, drums.

Preset 4: Ambient Cloud

🌫️ Evolving Ambient Texture

ParameterValueEffect
Total duration10.0 sLong, evolving
Grain duration0.15 s (150 ms)Medium grains
Generations4Moderate complexity
Window shapeBell (Hanning)Smooth, ethereal
Read modeRandom OffsetNon-linear texture

Result: Slow-evolving ambient pad. Good for drones, atmospheric sounds.

Preset 5: Percussive

🎯 Rhythmic Emphasis

ParameterValueEffect
Total duration4.0 sMedium length
Grain duration0.08 s (80 ms)Short but not too short
Generations3Sparse = clear rhythm
Window shapePlateauPercussive attack
Read modeSequential ScanProgressive variation

Result: Clear rhythmic pattern with evolving timbre. Good for drum loops, percussive sounds.

Parameters Explained

Output Structure Parameters

⏱️ Total_duration_(s)

Range: 1.0 - 30.0 seconds (practical limit based on grains)

Default: 4.0 seconds

Effect on fractal: Determines time span for pattern generation. Longer durations create more spaced-out patterns (same number of generations but larger intervals).

Musical considerations:

  • 1-3 s: Short textures, effects
  • 4-8 s: Musical phrases
  • 9-15 s: Evolving textures
  • 16-30 s: Long-form ambient

🎡 Grain_duration_(s)

Range: 0.01 - 0.5 seconds (10-500 ms)

Default: 0.1 seconds (100 ms)

Perceptual effects:

DurationPerceptionUse Case
10-30 msClick, glitch, graininessGlitch effects, granular clouds
40-80 msArticulated, percussiveRhythmic patterns, staccato
100-200 msNote-like, sustainedMelodic, phrase-based
250-500 msTextural, pad-likeAmbient, background textures

🌳 Generations

Range: 1 - 8 (practical limit for 4s duration)

Default: 5

Mathematical effect: Number of fractal iterations. Each generation adds grains at half-intervals between existing grains.

Number of grains β‰ˆ 2^(generations) - 1 (before mirroring) Examples: Generations=1: ~1 grain (before mirroring: 2 total) Generations=3: ~7 grains (before mirroring: 14 total) Generations=5: ~31 grains (before mirroring: 62 total) Generations=7: ~127 grains (before mirroring: 254 total)

Too many generations: May exceed Praat's memory or create overly dense textures.

Envelope & Reading Parameters

ParameterOptionsEffectBest With
Window_shapeBell (Hanning) / Plateau (Trapezoid)Controls grain envelope smoothnessBell: pads, clouds
Plateau: rhythms, percussion
Read_modeRandom Offset / Sequential ScanHow source audio is read for grainsRandom: textures
Sequential: melodies, speech
StereoYes / NoConvert mono to stereo (source stays stereo)Yes: spatial width
No: mono compatibility
NormalizeYes / NoScale peak to 0.95 (prevents clipping)Yes: safe playback
No: preserve dynamics
Draw_visualizationYes / NoShow fractal pattern and waveformsYes: understanding
No: faster processing

Visualization Guide

πŸ“Š Understanding the Graphical Output

Six visualization panels:

PanelContentPurpose
TitleScript name, source filenameContext
Source WaveformOriginal audio (gray)Reference material
Fractal Timing DiagramGrains by generation (colored bars)Show fractal structure
Generation LegendColor key for generationsIdentify hierarchy
Output WaveformResulting granular texture (green)Show final audio
Event TimelineVertical lines at grain positionsShow temporal density
StatisticsParameters and event countDocument settings

Color Coding by Generation

Generation Colors (RGB): Gen 0: {0.2, 0.4, 0.8} (Dark blue) Gen 1: {0.3, 0.6, 0.9} (Medium blue) Gen 2: {0.5, 0.7, 0.95} (Light blue) Gen 3: {0.6, 0.8, 0.97} (Pale blue) Gen 4: {0.7, 0.85, 0.98} (Very pale blue) Gen 5+: {0.8, 0.9, 0.99} (Almost white)

Interpretation: Darker colors = earlier generations (parent grains). Lighter colors = later generations (children grains). Shows hierarchical structure visually.

Reading the Fractal Timing Diagram

Y-axis (vertical): Generation number (0 to GENERATIONS)

X-axis (horizontal): Time (0 to total_duration)

Pivot line: Vertical dashed line at center (total_duration/2)

Colored bars: Each bar represents one grain:

  • Width: grain_duration
  • Height: 0.8 units (centered on generation)
  • Color: Based on generation
  • Position: Exact timing with jitter

Look for patterns:

  • Symmetry: Pattern should mirror around pivot
  • Hierarchy: Gen 0 grains as anchors, later gens fill gaps
  • Density gradient: More grains in middle, fewer at edges
  • Jitter effect: Small random timing variations

Event Timeline Interpretation

Simple representation: Vertical lines at each grain start time, colored by generation.

What to observe:

  • Temporal density: Where are grains clustered?
  • Symmetry: Left/right mirroring
  • Generation distribution: Are all generations evenly represented?
  • Gaps: Areas with no grains (silence)

Density patterns: Should show fractal distribution - dense where many generations overlap, sparse at edges.

Applications & Examples

Sound Design & Textures

🎨 Transforming Simple Sounds

Example 1: Voice β†’ Granular Cloud

  1. Source: Sustained vowel ("aaaah")
  2. Preset: Dense Texture
  3. Result: Evolving vocal pad texture

Example 2: Percussion β†’ Rhythmic Pattern

  1. Source: Single drum hit
  2. Preset: Percussive
  3. Adjust: grain_duration = 0.06 s, generations = 4
  4. Result: Complex rhythmic pattern from single hit

Example 3: Field Recording β†’ Ambient

  1. Source: Forest recording (30 seconds)
  2. Preset: Ambient Cloud
  3. Adjust: total_duration = 15.0 s, read_mode = Random
  4. Result: Abstracted environmental texture

Musical Composition

🎢 Generating Rhythmic Material

Technique 1: Fractal Rhythm Generation

  1. Source: Short melodic fragment (piano, synth)
  2. Use Sequential Scan read mode
  3. Preset: Sparse Rhythmic
  4. Result: Fractal variation of melody with inherent rhythm

Technique 2: Layered Textures

  1. Process same source with different parameters
  2. Layer results (e.g., dense cloud + sparse rhythm)
  3. Pan layers differently in DAW
  4. Add reverb/delay to taste

Technique 3: Parameter Automation

  1. Create multiple versions with evolving parameters
  2. Crossfade between versions over time
  3. Example: generations 2β†’6, grain_duration 0.2β†’0.05

Experimental & Academic

πŸ”¬ Perceptual Studies

Research applications:

  • Rhythm perception: How do we perceive fractal vs. regular rhythms?
  • Auditory streaming: At what density do grains fuse vs. separate?
  • Memory & expectation: How does symmetry affect musical expectation?
  • Timbre perception: How does grain duration affect source recognition?

Experimental design:

  1. Systematically vary one parameter (e.g., generations)
  2. Generate stimulus set
  3. Run listening tests (similarity, preference, identification)
  4. Analyze results statistically

Creative Processing Chain

⚑ Advanced Processing Pipeline

1. SOURCE PREPARATION: Original β†’ [Time-stretch 200%] β†’ [Add reverb] β†’ Prepared source 2. FRACTAL PROCESSING: Prepared source β†’ [Fractal Granulator] β†’ Preset: Dense Texture β†’ Texture layer Same source β†’ [Fractal Granulator] β†’ Preset: Sparse Rhythmic β†’ Rhythm layer 3. POST-PROCESSING: Texture layer β†’ [Low-pass filter] β†’ [Side-chain compression] Rhythm layer β†’ [Transient shaper] β†’ [Delay] 4. MIXING: Blend layers 70% texture / 30% rhythm Add global reverb Final mastering

Result: Professionally produced granular composition with depth and movement.