Polyrhythms From Dots — User Guide

Visual and auditory polyrhythm generator: creates complex rhythmic patterns using dot notation with stereo panning and visual display.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 2.0 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script implements polyrhythm generation from dot notation — a comprehensive tool for creating, visualizing, and hearing complex rhythmic patterns where two different rhythms play simultaneously. The system generates both visual dot patterns and corresponding audio with stereo panning, making it ideal for rhythm education, composition, and analysis.

Key Features:

What are polyrhythms? Traditional rhythms: single meter, uniform subdivisions. Polyrhythms: Simultaneous playing of two or more conflicting rhythms that create complex patterns. Advantages: (1) Rhythmic complexity: Creates rich, layered textures. (2) Cross-cultural relevance: Found in African, Indian, and contemporary music. (3) Educational value: Develops rhythmic coordination and perception. (4) Compositional tool: Adds sophistication to musical works. (5) Visual representation: Dot notation makes complex rhythms accessible. Use cases: Music education (rhythm training), composition (creating complex patterns), ethnomusicology (studying world rhythms), percussion practice (coordination development), music therapy (rhythmic stimulation).

Technical Implementation: (1) Rhythm Calculation: Computes timing based on bar duration and number of dots. (2) Visual Generation: Draws circle patterns representing rhythmic events. (3) Audio Synthesis: Creates sine wave bursts at rhythmic positions. (4) Stereo Processing: Applies panning to separate rhythmic layers spatially. (5) Preset System: Pre-configured musical polyrhythms with optimized parameters. (6) Customization: Flexible parameter control for unique creations. (7) Quality Control: Automatic naming and cleanup for smooth workflow.

Quick start

  1. In Praat, ensure no objects are selected (script creates new sounds).
  2. Run script…polyrhythms_from_dots.praat.
  3. Choose Preset or select "Custom" for manual control.
  4. If using custom, set dots1 and dots2 for each rhythm.
  5. Adjust barDuration for overall timing (seconds).
  6. Set dotDur for individual note length.
  7. Configure baseFreq and amplitude for sound character.
  8. Adjust panAmount for stereo separation.
  9. Click OK — visual display appears and sound plays automatically.
Quick tip: Start with 3 vs 4 (Waltz) preset for a classic polyrhythm. Use headphones to appreciate the stereo panning effects. The top line (left channel) uses the base frequency, while the bottom line (right channel) plays at 1.5× the base frequency. Dots are spaced evenly within the bar duration — more dots = faster rhythm. The visual display helps understand the rhythmic relationship between the two patterns. For educational use, try simpler ratios like 2:3 or 3:4 first before moving to complex ones like 5:7 or 7:8.
Important: RHYTHM COMPLEXITY — Very high numbers (like 13:17) can create extremely dense patterns that are difficult to perceive. BAR DURATION affects clarity — very short durations with many dots create rapid-fire effects. DOT DURATION that's too long may cause overlapping sounds and reduced clarity. STEREO PANNING is subtle with small panAmount values — use 0.8-1.0 for clear separation. VISUAL DISPLAY uses fixed vertical positions — complex rhythms may have crowded dots. The script automatically cleans up temporary objects, preserving only the final stereo sound.

Polyrhythm Theory

What are Polyrhythms?

🎵 Simultaneous conflicting rhythms

Definition: Two or more independent rhythms with different subdivisions played together

Mathematical basis: Ratio of rhythmic densities (e.g., 3:4, 5:7)

Musical effect: Creates tension, complexity, and rhythmic interest

Basic polyrhythm concept:

Polyrhythm X:Y means: - One rhythm plays X evenly spaced notes - Another rhythm plays Y evenly spaced notes - Both rhythms fit within the same time period (bar) Example: 3:4 polyrhythm Rhythm A: 3 notes evenly spaced in 1 bar Rhythm B: 4 notes evenly spaced in 1 bar Result: Complex pattern that repeats every bar Timing calculation: spacing1 = barDuration / dots1 spacing2 = barDuration / dots2 For 3:4 with 2-second bar: Rhythm A: notes at 0.0, 0.667, 1.333 seconds Rhythm B: notes at 0.0, 0.5, 1.0, 1.5 seconds

Common Polyrhythm Types

Simple Ratios (2:3, 3:4)

Characteristics and uses:

2:3 Polyrhythm: - Most fundamental polyrhythm - Common in African and Latin music - Creates "hemiola" effect - Easy to perceive and perform 3:4 Polyrhythm: - Classic "3 against 4" - Foundation of many jazz and classical patterns - Creates waltz-like feeling - Clearly distinguishable layers Musical applications: - Cross-rhythms in percussion - Piano left hand vs right hand - Melodic accompaniment patterns - Drum set coordination exercises

Complex Ratios (5:7, 7:8, 5:9)

Advanced polyrhythms:

5:7 Polyrhythm: - Medium complexity - Common in progressive rock - Creates mathematical precision - Repeats every 35 subdivisions (5×7) 7:8 Polyrhythm: - High density - Used in fusion and math rock - Creates busy, intricate texture - Challenging to perform accurately 5:9 Polyrhythm: - Very complex - Extreme math rock and metal - Creates disorienting effect - Repeats every 45 subdivisions Perception challenge: Complex ratios create less obvious patterns Require multiple repetitions to grasp Benefit from visual representation

Mathematical Foundation

Least Common Multiple and Pattern Repetition

When do patterns repeat?

Pattern repetition occurs at: LCM(dots1, dots2) × (barDuration / dots1 / dots2) Where LCM = Least Common Multiple Examples: 3:4 polyrhythm: LCM(3,4) = 12 Repeats every 12 subdivisions In 2-second bar: repeats every 2×(12/12) = 2 seconds 5:7 polyrhythm: LCM(5,7) = 35 Repeats every 35 subdivisions In 3.5-second bar: repeats every 3.5×(35/35) = 3.5 seconds Musical significance: Simple ratios repeat quickly (easier to learn) Complex ratios repeat slowly (harder to perceive) Prime number ratios create longest patterns

Phase Relationships

How rhythms interact over time:

Phase calculation: For dots1 and dots2, phase alignment occurs when: (time / spacing1) mod 1 = (time / spacing2) mod 1 This happens at times: t = k × barDuration / GCD(dots1, dots2) Where GCD = Greatest Common Divisor k = 0, 1, 2, ... Example: 3:4 polyrhythm GCD(3,4) = 1 Alignment at: 0, barDuration, 2×barDuration, ... Example: 4:6 polyrhythm (reducible to 2:3) GCD(4,6) = 2 Alignment at: 0, barDuration/2, barDuration, ...

Rhythm Presets

Preset 1: 3 vs 4 (Waltz)

🎵 Classic Three Against Four

Musical character: Flowing, dance-like, elegant

Cultural origins: European classical, jazz standards

Best for: Introduction to polyrhythms, waltz variations

Preset parameters:

dots1 = 3 (top rhythm) dots2 = 4 (bottom rhythm) barDuration = 3.0 seconds baseFreq = 196 Hz (G3) Sound design: Top: 196 Hz sine waves Bottom: 294 Hz sine waves (196 × 1.5) Clear pitch separation for easy tracking Visual spacing: Top: dots at 0.0, 1.0, 2.0 seconds Bottom: dots at 0.0, 0.75, 1.5, 2.25 seconds

Preset 2: 5 vs 7 (Complex)

🎵 Medium Complexity

Musical character: Mathematical, precise, intricate

Cultural origins: Progressive rock, fusion

Best for: Intermediate study, composition ideas

Preset parameters:

dots1 = 5 (top rhythm) dots2 = 7 (bottom rhythm) barDuration = 3.5 seconds baseFreq = 220 Hz (A3) Pattern characteristics: Repeats every LCM(5,7) = 35 subdivisions Creates non-obvious rhythmic relationships Challenging but perceptible with repetition Musical applications: Drum set coordination Piano rhythm studies Contemporary composition

Preset 3: 2 vs 3 (Simple)

🎵 Fundamental Polyrhythm

Musical character: Basic, foundational, cross-rhythmic

Cultural origins: African, Latin American

Best for: Beginners, rhythm fundamentals

Preset 4: 4 vs 5 (Jazz)

🎵 Jazz Quarter-Note Feel

Musical character: Swinging, sophisticated, modern

Cultural origins: Jazz, contemporary classical

Best for: Jazz studies, modern composition

Preset 5: 3 vs 5 (African)

🎵 Cross-Cultural Pattern

Musical character: Organic, layered, traditional

Cultural origins: West African, Afro-Cuban

Best for: World music studies, percussion

Preset 6: 7 vs 8 (Dense)

🎵 High-Density Texture

Musical character: Complex, busy, virtuosic

Cultural origins: Fusion, math rock, contemporary

Best for: Advanced study, complex textures

Preset 7: 4 vs 7 (Progressive)

🎵 Progressive Rock Feel

Musical character: Driving, mathematical, energetic

Cultural origins: Progressive rock, metal

Best for: Rock applications, rhythmic intensity

Preset 8: 5 vs 9 (Math Rock)

🎵 Extreme Complexity

Musical character: Intricate, disorienting, mathematical

Cultural origins: Math rock, experimental

Best for: Advanced rhythm concepts, experimental music

Preset Comparison Table

PresetRatioComplexityBar DurationMusical Style
2 vs 32:3Beginner2.0sFundamental
3 vs 43:4Easy3.0sWaltz/Classical
3 vs 53:5Intermediate2.5sAfrican
4 vs 54:5Intermediate4.0sJazz
4 vs 74:7Advanced3.0sProgressive
5 vs 75:7Advanced3.5sComplex
5 vs 95:9Expert5.0sMath Rock
7 vs 87:8Expert4.0sDense

Visual Display System

Dot Notation

● Visual Rhythm Representation

Concept: Each dot represents a rhythmic event in time

Layout: Top line = left channel, Bottom line = right channel

Spacing: Even distribution across bar duration

Visual generation algorithm:

FOR each rhythm (dots1 and dots2): spacing = barDuration / number_of_dots FOR i from 1 to number_of_dots: x_position = (i - 1) × spacing IF top rhythm: y_position = 0.8 IF bottom rhythm: y_position = 0.2 Draw circle: x_position, y_position, dotRadius Example: 3:4 polyrhythm with 2-second bar Top (3 dots): x = 0.0, 0.667, 1.333 Bottom (4 dots): x = 0.0, 0.5, 1.0, 1.5 Vertical separation: top at 0.8, bottom at 0.2 Visual benefits: Clear timing relationships Pattern repetition visible Phase alignment obvious Educational value

Stereo Panning System

Spatial Rhythm Separation

Panning calculation:

For each dot in a rhythm: panPos = -1 + (2 × (i - 1) / (dots - 1)) panPos = panPos × panAmount Where: i = dot index (1 to dots) dots = total dots in rhythm panAmount = user control (0.0 to 1.0) Left/right amplitude: leftAmp = amplitude × (1 - panPos) / 2 rightAmp = amplitude × (1 + panPos) / 2 Panning behavior: First dot: panned left (panPos ≈ -panAmount) Middle dot: center (panPos ≈ 0) Last dot: panned right (panPos ≈ +panAmount)

Panning Examples

Different panning scenarios:

Example 1: 3 dots with panAmount = 0.8 Dot 1: panPos = -0.8 → strong left Dot 2: panPos = 0.0 → center Dot 3: panPos = +0.8 → strong right Example 2: 4 dots with panAmount = 0.5 Dot 1: panPos = -0.5 → moderate left Dot 2: panPos = -0.167 → slight left Dot 3: panPos = +0.167 → slight right Dot 4: panPos = +0.5 → moderate right Musical effect: Creates spatial movement through pattern Helps distinguish rhythmic layers Adds psychoacoustic interest Mimics natural performance spatialization

Audio Synthesis

Sine Wave Generation

Sound creation algorithm:

FOR each dot in each rhythm: startTime = (i - 1) × spacing endTime = startTime + dotDur IF top rhythm: frequency = baseFreq IF bottom rhythm: frequency = baseFreq × 1.5 Calculate panning amplitudes (leftAmp, rightAmp) Sound formula: "self + if x >= startTime and x < endTime" "then amplitude × sin(2×π×frequency×(x - startTime))" "else 0 fi" Applied separately to left and right channels Result: Brief sine wave bursts at rhythmic positions

Sound Design Considerations

Parameter effects on sound character:

baseFreq effects: Low values (100-200 Hz): Warm, fundamental Medium values (200-400 Hz): Clear, present High values (400-800 Hz): Bright, piercing dotDur effects: Short (0.02-0.05s): Percussive, staccato Medium (0.05-0.1s): Tonal, defined Long (0.1-0.2s): Sustained, overlapping amplitude effects: Low (0.1-0.3): Subtle, background Medium (0.3-0.7): Clear, foreground High (0.7-1.0): Loud, potentially clipping Frequency ratio: Top: baseFreq (e.g., 220 Hz) Bottom: baseFreq × 1.5 (e.g., 330 Hz) Creates perfect fifth interval (musical)

Applications

Music Education

Use case: Teaching polyrhythm concepts and coordination

Technique: Start with simple ratios, progress to complex ones

Settings: Use visual display and stereo separation for clarity

Composition and Arranging

Use case: Creating complex rhythmic patterns for music

Technique: Experiment with unusual ratios for unique textures

Settings: Custom rhythms with musical parameter tuning

Percussion Practice

Use case: Developing limb independence and coordination

Technique: Assign rhythms to different limbs/hands

Settings: Use panning to simulate different drum positions

Music Therapy

Use case: Rhythmic stimulation and coordination therapy

Technique: Use simpler ratios for motor skill development

Settings: Gentle amplitudes, comfortable frequency ranges

Ethnomusicology Research

Use case: Studying rhythmic patterns from world music

Technique: Recreate documented polyrhythms for analysis

Settings: Culturally appropriate ratios and timings

Practical Workflow Examples

🎓 Rhythm Education Session

Goal: Introduce students to polyrhythm concepts

Settings:

  • Start with: 2 vs 3 (Simple)
  • Progress to: 3 vs 4 (Waltz)
  • Advanced: 4 vs 5 (Jazz)
  • barDuration: 3.0-4.0 seconds
  • panAmount: 0.8 (clear separation)

Result: Gradual understanding of increasing complexity

🥁 Drum Set Coordination

Goal: Develop limb independence for drummers

Settings:

  • Rhythm: 3 vs 4 or 4 vs 5
  • barDuration: 2.0-3.0 seconds
  • dotDur: 0.03-0.05s (percussive)
  • baseFreq: Different for each limb

Result: Improved coordination between hands and feet

🎵 Contemporary Composition

Goal: Create unique rhythmic material for composition

Settings:

  • Rhythm: 5 vs 7 or 7 vs 8
  • barDuration: 4.0-5.0 seconds
  • Complex patterns for texture
  • Experiment with extreme parameters

Result: Sophisticated rhythmic foundation for pieces

Creative Techniques

Progressive learning approach:
  • Start simple: 2:3, 3:4 with longer durations
  • Add complexity: 4:5, 3:5 with moderate durations
  • Advanced patterns: 5:7, 4:7 with musical timing
  • Expert challenges: 7:8, 5:9 with precise parameters
  • Custom exploration: Prime number ratios for uniqueness
Parameter experimentation:
  • Vary barDuration: Affects pattern clarity and speed
  • Adjust dotDur: Changes sound character from staccato to legato
  • Modify panAmount: Controls spatial separation intensity
  • Change frequencies: Creates different musical intervals
  • Custom ratios: Discover unique polyrhythmic relationships

Troubleshooting Common Issues

Problem: Rhythms sound muddy or unclear
Cause: Too many dots, short bar duration, long dot duration
Solution: Use simpler ratio, increase bar duration, shorten dot duration
Problem: No stereo effect audible
Cause: Low panAmount, mono playback, similar rhythms
Solution: Increase panAmount, use headphones, choose distinct ratios
Problem: Visual display too crowded
Cause: High dot counts, small display area
Solution: Use simpler rhythms, increase bar duration for spacing
Problem: Sound is too quiet or too loud
Cause: Extreme amplitude values, system volume issues
Solution: Use amplitude 0.3-0.7, check system audio levels
Problem: Cannot perceive the polyrhythm
Cause: Too complex ratio, unfamiliar pattern
Solution: Start with 2:3 or 3:4, listen multiple times, use visual aid

Technical Reference

Complete Parameter Reference

ParameterTypeDefaultDescription
Presetoptionmenu1Pre-configured rhythm patterns
dots1integer5Number of dots in top rhythm (left channel)
dots2integer7Number of dots in bottom rhythm (right channel)
barDurationreal2.0Total duration of pattern in seconds
dotDurreal0.05Duration of each individual dot sound
baseFreqreal220Base frequency for top rhythm in Hz
samplerateinteger22050Audio sampling rate in Hz
dotRadiusreal0.01Visual size of dots in normalized units
amplitudereal0.5Overall sound amplitude (0.0-1.0)
panAmountreal0.8Stereo panning intensity (0.0-1.0)

Output Characteristics

Generated Sound Properties

Technical specifications:

Output object: "polyrhythm_X_Y_panned" (where X=dots1, Y=dots2) Type: Stereo Sound Channels: 2 (left, right) Duration: barDuration seconds Sampling frequency: samplerate Hz Content: Sine wave bursts at rhythmic positions Spectral content: Top rhythm: baseFreq (fundamental only) Bottom rhythm: baseFreq × 1.5 (perfect fifth above) Pure tones without harmonics

Performance Characteristics

Processing Time Factors

Major time consumers:

1. Sound object creation: O(1) constant 2. Dot drawing: O(dots1 + dots2) linear 3. Sound synthesis: O(samplerate × barDuration × (dots1 + dots2)) Dominant factor: Sound synthesis formulas Complexity increases with: - Higher samplerate - Longer barDuration - More dots in rhythms Typical performance: Simple rhythms (2:3, 3:4): <1 second Complex rhythms (5:7, 7:8): 1-3 seconds Extreme cases (11:13): 3-5 seconds

Memory Usage

Storage requirements:

Major objects: Left channel sound: samplerate × barDuration samples Right channel sound: samplerate × barDuration samples Final stereo sound: 2 × samplerate × barDuration samples Typical usage: 2-second bar, 22050 Hz: ~88,200 samples per channel Total memory: ~176,400 samples × 4 bytes ≈ 0.7 MB Efficient for all practical applications Automatic cleanup of temporary objects