Percussive Groove Pattern Creator — User Guide
Automatic drum pattern generation: detects bass drums, hi-hats, and snares from audio and creates algorithmic groove patterns with customizable styles.
What this does
This script implements automatic percussive groove creation — an intelligent approach to rhythm generation that analyzes audio files to detect percussive events (bass drums, hi-hats, snares) and reassembles them into musically coherent drum patterns. The process: (1) Audio Analysis: Detects sharp amplitude onsets and classifies them by spectral content. (2) Event Classification: Groups detected sounds into three categories: bass drums (low-frequency dominant), hi-hats (high-frequency dominant), and snares (mid-frequency dominant). (3) Pattern Generation: Arranges classified sounds according to selected beat patterns (standard 4/4, funk, breakbeat, etc.) with adjustable density and timing variations. (4) Dynamic Processing: Applies envelope shaping, velocity variation, and optional stereo imaging.
Key Features:
- Intelligent Detection — Automatically identifies bass drums, hi-hats, and snares from any audio
- 6 Beat Patterns — Standard 4/4, Syncopated Funk, Breakbeat, Half-time, Double-time, Sparse Minimal
- Customizable Density — Control pattern complexity from sparse to dense
- Dynamic Shaping — Adjustable attack/release envelopes and velocity variation
- Stereo/Mono Output — Create mono patterns or stereo variations
- Flexible Length — 1-bar, 2-bar, or 4-bar patterns
- Tempo Control — Set any BPM from 60-240
Technical Implementation: (1) Onset Detection: Analyze intensity contour, detect sharp amplitude peaks above threshold. (2) Spectral Classification: For each detected onset, analyze frequency band energies (low: 20-250Hz, mid: 250-4000Hz, high: 4000-18000Hz) to classify as bass drum (low dominant), hi-hat (high dominant), or snare (mid dominant). (3) Pattern Logic: Based on selected pattern type, probabilistically place sounds on sixteenth-note grid according to musical rules for that style. (4) Dynamic Processing: Apply customizable attack/release envelopes with shape control, random velocity variation (60-100%). (5) Assembly: Mix processed sounds into final pattern, with optional stereo variation for width. Key insight: The script doesn't require pre-classified samples — it intelligently extracts and categorizes percussive sounds from any audio material.
Quick start
- In Praat, select any Sound object containing percussive content.
- Run script… →
percussive_groove_creator.praat. - Set Pattern_length: 1 bar (simple), 2 bars (standard), or 4 bars (complex).
- Choose Beat_pattern: Start with "Standard 4/4" for familiar patterns.
- Set Tempo (BPM) to match your project (default 120).
- Adjust Onset_threshold to control detection sensitivity (default -20dB).
- Set Groove_density to control pattern complexity (0.1=sparse, 1.0=dense).
- Enable Create_stereo for wider, more interesting patterns.
- Click OK — pattern is generated, named "originalname_groove_Xbar".
Percussive Event Detection
Onset Detection Algorithm
🔊 Intensity-Based Peak Detection
Process:
- Convert audio to intensity contour (70Hz analysis, 0 smoothing)
- Scan for local maxima in intensity
- Compare current value to previous and next frames
- Threshold at user-defined dB level (-20dB default)
- Enforce minimum silence between events (0.05s default)
Mathematical check: event detected if:
intensity[frame] > intensity[frame-1] AND
intensity[frame] > intensity[frame-2] AND
intensity[frame] > intensity[frame+1] AND
intensity[frame] > onset_threshold
Spectral Classification
Three-Band Energy Analysis
Why These Frequency Ranges?
Spectral characteristics of drum sounds:
- Bass Drums: Energy concentrated below 250Hz (fundamental and harmonics)
- Snares: Broad midrange emphasis (250-4000Hz for body and snare wires)
- Hi-hats/Cymbals: Bright, high-frequency content above 4000Hz
- Toms: Often fall between bass and snare ranges
- Clean sources: Isolated drum hits classify most accurately
- Mixed audio: May require threshold adjustments
- Electronic vs acoustic: Electronic drums often have purer spectral profiles
- Room sound: Reverb can blur frequency boundaries
- If misclassification occurs: Try different source audio or adjust Max_segment_duration
Detection Parameters
| Parameter | Default | Effect | Typical Range |
|---|---|---|---|
| Onset_threshold | -20 dB | Detection sensitivity | -30 (sensitive) to -10 (strict) |
| Min_silence_between_events | 0.05 s | Prevents double-triggers | 0.02 to 0.2 s |
| Max_segment_duration | 0.15 s | Length analyzed for classification | 0.05 to 0.3 s |
- Too few events detected: Lower onset_threshold, check audio has clear transients
- Too many false positives: Raise onset_threshold, increase min_silence_between_events
- Poor classification: Adjust Max_segment_duration to capture full attack portion
- Missing sound types: Source audio may not contain all drum types
Beat Pattern Algorithms
🎵 Pattern Generation Logic
Core principle: Each pattern type has predefined rules for which sounds to place on which sixteenth-note positions, with probability controlled by groove_density parameter.
Grid: Pattern divided into bars × beats × sixteenths
Placement: For each sixteenth position, algorithm determines if a sound should be placed and what type (bass, snare, hi-hat)
Pattern 1: Standard 4/4
Pattern 2: Syncopated Funk
Pattern 3: Breakbeat
Pattern 4: Half-time Feel
Pattern 5: Double-time Feel
Pattern 6: Sparse Minimal
Probability and Randomization
Parameters & Settings
Pattern Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Pattern_length | option | 2 bars | 1, 2, or 4 bars |
| Beat_pattern | option | Standard 4/4 | 6 pattern styles |
| Tempo (BPM) | real | 120 | Beats per minute |
| Groove_density | real | 0.6 | 0.1 (sparse) to 1.0 (dense) |
| Create_stereo | boolean | yes | Create stereo pattern |
Detection Parameters
| Parameter | Default | Description |
|---|---|---|
| Onset_threshold | -20 dB | Minimum intensity for detection |
| Min_silence_between_events | 0.05 s | Prevents double triggers |
| Max_segment_duration | 0.15 s | Maximum length analyzed |
Sound Processing Parameters
| Parameter | Default | Description |
|---|---|---|
| Clip_max_length | 0.12 s | Maximum sound duration |
| Attack_time | 0.002 s | Envelope attack time |
| Release_time | 0.05 s | Envelope release time |
| Shape_intensity | 1.2 | Envelope curve shape |
Parameter Interactions
- Groove_density × Pattern_length: Longer patterns with high density can become overwhelming
- Tempo × Clip_max_length: Faster tempos may require shorter clips
- Attack_time × Sound material: Very short attack times (0.001s) work best with sharp transients
- Onset_threshold × Source loudness: Adjust relative to your audio's peak level
- Pattern_type × Groove_density: Some patterns (like Sparse Minimal) maintain sparseness even at high density
Workflow Examples
Quick Drum Track Creation
🎬 From Breakbeat to Custom Pattern
Goal: Create unique drum pattern from classic breakbeat
Source: "Amen Brother" or similar breakbeat sample
Settings:
- Pattern_length: 2 bars
- Beat_pattern: Breakbeat
- Tempo: 140 BPM
- Groove_density: 0.7
- Onset_threshold: -22 dB
- Create_stereo: yes
Result: New breakbeat-inspired pattern with similar feel but unique arrangement
Experimental Texture Creation
🎵 From Field Recording to Rhythm
Goal: Create rhythmic pattern from non-musical sounds
Source: Field recording of construction site, kitchen sounds, etc.
Settings:
- Pattern_length: 4 bars
- Beat_pattern: Sparse Minimal
- Tempo: 90 BPM
- Groove_density: 0.4
- Onset_threshold: -18 dB (more selective)
- Clip_max_length: 0.2 s (longer textures)
Result: Ambient rhythmic texture with found sounds
Drum Sound Library Organization
📚 Categorizing Random Drum Hits
Goal: Automatically sort folder of drum samples
Source: Folder of unlabeled drum hits
Workflow:
- Concatenate all samples into one long sound
- Run script with very low Groove_density (0.1)
- Script detects and classifies each hit
- Output shows counts of each type
- Manually verify and organize based on classification
Result: Preliminary categorization of unknown samples
Common Workflows
| Use Case | Recommended Settings | Tips |
|---|---|---|
| Traditional Rock | Pattern 1, Density 0.6-0.8, 2 bars | Use drum kit recordings |
| Hip-Hop | Pattern 4, Tempo 70-90, Density 0.5 | Add swing manually after |
| Techno | Pattern 1 or 5, Tempo 120-140, Density 0.8 | Use electronic drum sounds |
| Ambient | Pattern 6, Tempo 60-80, Density 0.3 | Long attack/release times |
| Jazz | Pattern 2, Density 0.5-0.7, Stereo yes | Use acoustic kit recordings |
Advanced Techniques
Layering Patterns
- Generate multiple patterns from same source with different settings
- Mix patterns together in Praat or DAW
- Example: Layer sparse pattern (density 0.3) with dense pattern (density 0.8)
- Result: More complex, evolving rhythm
Tempo Automation
- Generate pattern at base tempo
- Use Praat's "Lengthen (overlap-add)" to change tempo without pitch
- Or generate multiple patterns at different tempos and crossfade
- For gradual tempo changes: Generate long pattern, then apply time-stretching
Hybrid Pattern Creation
- Generate pattern A (e.g., Standard 4/4)
- Generate pattern B (e.g., Breakbeat)
- Extract bass from A, snares from B, hi-hats from both
- Reassemble in Praat using matrix operations
- Result: Hybrid pattern with characteristics of both styles
Post-Processing Techniques
Troubleshooting Common Issues
Cause: Too perfect timing, no humanization
Solutions:
- Use lower groove_density for more space
- Generate stereo version for natural variation
- Add slight timing variations manually after generation
- Use more varied source material
Cause: Clip_max_length too short, or sounds placed too close together
Solutions:
- Increase Clip_max_length (0.15-0.25s)
- Increase Min_silence_between_events
- Use sparser groove_density
- Increase Release_time for smoother fadeouts
Cause: Left/right channels too different
Solutions:
- Use mono version instead
- Manually align some hits between channels
- Use similar random seed for both channels (not implemented in current version)
- Apply mild stereo widening instead of full independent generation
Cause: Source material has ambiguous spectral content
Solutions:
- Use cleaner source material
- Pre-filter audio (high-pass for hi-hats, etc.)
- Manually verify and adjust classification thresholds in code
- Use multiple source files with clear examples of each sound type
Creative Applications
- Glitch/IDM: Use very short Clip_max_length (0.02-0.05s) for stutter effects
- Polyrhythms: Generate patterns at different tempos and layer
- Granular textures: High density + very short clips = granular synthesis
- Educational tool: Demonstrate different rhythmic styles
- Composition starter: Generate pattern, then compose melody/harmony to fit
- Sound design: Use non-percussive sounds to create "rhythmic textures"