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.

Author: Audio Tools Team Version: 1.0 (2024) License: MIT License Category: Audio Analysis & Rhythm Generation
Contents:

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:

What are algorithmic groove patterns? Traditional drum programming: manual placement of samples on a grid. Algorithmic groove generation: automatic pattern creation based on detected sounds and musical rules. Advantages: (1) Time-saving: Automatically extracts usable sounds from any audio source. (2) Creative inspiration: Generates unexpected patterns from source material. (3) Consistency: Maintains musical coherence within selected style. (4) Adaptability: Works with any percussive audio material. (5) Variation: Creates unique patterns each time with controlled randomness. Use cases: Music production (quick drum tracks), sound design (rhythmic textures), sample library creation (extracting drum hits), experimental composition (algorithmic rhythms), education (rhythm pattern studies).

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

  1. In Praat, select any Sound object containing percussive content.
  2. Run script…percussive_groove_creator.praat.
  3. Set Pattern_length: 1 bar (simple), 2 bars (standard), or 4 bars (complex).
  4. Choose Beat_pattern: Start with "Standard 4/4" for familiar patterns.
  5. Set Tempo (BPM) to match your project (default 120).
  6. Adjust Onset_threshold to control detection sensitivity (default -20dB).
  7. Set Groove_density to control pattern complexity (0.1=sparse, 1.0=dense).
  8. Enable Create_stereo for wider, more interesting patterns.
  9. Click OK — pattern is generated, named "originalname_groove_Xbar".
Quick tip: Start with drum loop or breakbeat audio for best results. Use Onset_threshold = -25 to -15 dB to fine-tune detection (lower = more sensitive). Set Groove_density = 0.4-0.7 for natural-sounding patterns. Enable Create_stereo for more interesting results (creates slight variations between channels). Adjust Clip_max_length to control how long each sound plays (shorter = tighter, more defined). Use Attack_time = 0.002s and Release_time = 0.05s for punchy sounds. Pattern analysis shows detected counts of each sound type — aim for at least 3-5 of each type for best variation.
Important: SOURCE AUDIO QUALITY MATTERS — Clean, isolated percussive hits yield best classification. Complex mixes may produce misclassifications. Onset detection sensitivity critical — too high may miss sounds, too low may capture non-percussive transients. Not all audio will contain all three sound types — patterns use only detected types. Groove_density significantly affects pattern feel — high values create busy patterns, low values create sparse/groovy patterns. Tempo changes affect pattern duration — faster tempos = shorter patterns at same bar length. Stereo variation creates different patterns in left/right channels — not just panning. Random elements mean patterns vary each run even with same settings.

Percussive Event Detection

Onset Detection Algorithm

🔊 Intensity-Based Peak Detection

Process:

  1. Convert audio to intensity contour (70Hz analysis, 0 smoothing)
  2. Scan for local maxima in intensity
  3. Compare current value to previous and next frames
  4. Threshold at user-defined dB level (-20dB default)
  5. 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

For each detected onset segment: Extract segment: ±0.005s before, up to max_segment_duration after Convert to spectrum Calculate band energies: LOW (20-250Hz): bass drum range MID (250-4000Hz): snare/body range HIGH (4000-18000Hz): hi-hat/cymbal range Total energy = LOW + MID + HIGH Calculate ratios: low_ratio = LOW / total_energy mid_ratio = MID / total_energy high_ratio = HIGH / total_energy Classification rules: IF low_ratio > 0.55 → BASS DRUM ELSE IF high_ratio > 0.35 → HI-HAT ELSE IF mid_ratio > 0.4 → SNARE ELSE → reject (non-percussive/ambiguous)

Why These Frequency Ranges?

Spectral characteristics of drum sounds:

Classification tips:
  • 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

ParameterDefaultEffectTypical Range
Onset_threshold-20 dBDetection sensitivity-30 (sensitive) to -10 (strict)
Min_silence_between_events0.05 sPrevents double-triggers0.02 to 0.2 s
Max_segment_duration0.15 sLength analyzed for classification0.05 to 0.3 s
Detection troubleshooting:
  • 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

BASS: Beat 1 (always), Beat 3 (probability = groove_density) SNARE: Beats 2 and 4 (probability = groove_density + 0.2) HI-HAT: On beats (1,3) and off-beats (probability = groove_density × 0.8) Other sixteenths (probability = groove_density × 0.3) Example at groove_density = 0.6: Bass: 100% on 1, 60% on 3 Snare: 80% on 2 and 4 Hi-hat: 48% on beats, 18% on other sixteenths Result: Traditional rock/pop pattern

Pattern 2: Syncopated Funk

BASS: Beat 1 (always) Beat 2, sixteenth 4 (probability = groove_density) - anticipatory Beat 3, sixteenth 3 (probability = groove_density) - syncopated SNARE: Beats 2 and 4 (probability = groove_density + 0.2) HI-HAT: Most positions (probability = groove_density × 0.9) Character: Off-beat bass drum accents, constant hi-hat Example: James Brown, Parliament-Funkadelic style

Pattern 3: Breakbeat

BASS: Beat 1 (always) Beat 1, sixteenth 3 (probability = groove_density × 0.6) - double hit Beat 3, sixteenth 1 or 4 (probability = groove_density) SNARE: Beat 2 (always) Beat 4, sixteenth 1 or 3 (probability = groove_density) HI-HAT: Moderate density (probability = groove_density × 0.7) Character: Complex, syncopated, inspired by classic breakbeats Example: Amen break, Funky Drummer style patterns

Pattern 4: Half-time Feel

BASS: Every 2 bars on beat 1 (50% slower feel) SNARE: Every 2 bars on beat 3 (probability = groove_density) HI-HAT: On beats only (probability = groove_density × 0.6) Temporal feel: Pattern spans twice as many bars Character: Laid-back, hip-hop, dub Example: 70-85 BPM hip-hop grooves

Pattern 5: Double-time Feel

BASS: On beats and off-beats (probability = groove_density) SNARE: On off-beats (probability = groove_density × 0.8) HI-HAT: Most positions (probability = groove_density) Character: Fast, busy, energetic Temporal feel: Pattern feels twice as fast as tempo suggests Example: Jungle, drum & bass, fast punk

Pattern 6: Sparse Minimal

BASS: Beat 1 (always), Beat 3 (probability = 0.3) SNARE: Beat 2 (probability = groove_density × 0.5) HI-HAT: Every other beat (probability = groove_density × 0.4) Character: Minimal, spacious, atmospheric Density: Very low even at high groove_density settings Example: Ambient, minimal techno, dub techno

Probability and Randomization

For each sixteenth position: Generate random number: r = randomUniform(0, 1) IF pattern rule says "place type X with probability p" THEN IF r < p → place sound of type X Example: Standard 4/4, groove_density = 0.7, beat 3 snare placement Rule: snare on beat 3 with probability = groove_density + 0.2 = 0.9 Random number: r = 0.65 Since 0.65 < 0.9 → place snare Result: Consistent pattern structure with natural variation

Parameters & Settings

Pattern Parameters

ParameterTypeDefaultDescription
Pattern_lengthoption2 bars1, 2, or 4 bars
Beat_patternoptionStandard 4/46 pattern styles
Tempo (BPM)real120Beats per minute
Groove_densityreal0.60.1 (sparse) to 1.0 (dense)
Create_stereobooleanyesCreate stereo pattern

Detection Parameters

ParameterDefaultDescription
Onset_threshold-20 dBMinimum intensity for detection
Min_silence_between_events0.05 sPrevents double triggers
Max_segment_duration0.15 sMaximum length analyzed

Sound Processing Parameters

ParameterDefaultDescription
Clip_max_length0.12 sMaximum sound duration
Attack_time0.002 sEnvelope attack time
Release_time0.05 sEnvelope release time
Shape_intensity1.2Envelope curve shape

Parameter Interactions

Important relationships:
  • 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:

  1. Concatenate all samples into one long sound
  2. Run script with very low Groove_density (0.1)
  3. Script detects and classifies each hit
  4. Output shows counts of each type
  5. Manually verify and organize based on classification

Result: Preliminary categorization of unknown samples

Common Workflows

Use CaseRecommended SettingsTips
Traditional RockPattern 1, Density 0.6-0.8, 2 barsUse drum kit recordings
Hip-HopPattern 4, Tempo 70-90, Density 0.5Add swing manually after
TechnoPattern 1 or 5, Tempo 120-140, Density 0.8Use electronic drum sounds
AmbientPattern 6, Tempo 60-80, Density 0.3Long attack/release times
JazzPattern 2, Density 0.5-0.7, Stereo yesUse acoustic kit recordings

Advanced Techniques

Layering Patterns

Creating complex rhythms:
  1. Generate multiple patterns from same source with different settings
  2. Mix patterns together in Praat or DAW
  3. Example: Layer sparse pattern (density 0.3) with dense pattern (density 0.8)
  4. Result: More complex, evolving rhythm

Tempo Automation

Creating tempo changes:
  • 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

Mixing pattern types:
  1. Generate pattern A (e.g., Standard 4/4)
  2. Generate pattern B (e.g., Breakbeat)
  3. Extract bass from A, snares from B, hi-hats from both
  4. Reassemble in Praat using matrix operations
  5. Result: Hybrid pattern with characteristics of both styles

Post-Processing Techniques

Common post-processing in Praat: 1. ADD REVERB: Filter (formula): ~ self + 0.3*self[col-100] + 0.15*self[col-200] 2. ADD COMPRESSION: Formula: ~ if abs(self) > 0.5 then 0.5*sign(self) else self fi 3. ADD SATURATION: Formula: ~ tanh(self * 1.5) 4. ADD SWING: For every even sixteenth: shift by 0.01-0.03s 5. ADD FILTER SWEEP: Formula: ~ self * sin(2*pi*1000*x) (example: 1000Hz modulation)

Troubleshooting Common Issues

Problem: Pattern sounds robotic/metronomic
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
Problem: Sounds cut off abruptly
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
Problem: Stereo version sounds phasey/weird
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
Problem: Classification errors (hi-hats as snares, etc.)
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

Beyond drum patterns:
  • 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"