beatstoch

2 min read Original article ↗

Stochastic Drum Pattern Generator

Transform any song into unique, probabilistic MIDI drum patterns

[![PyPI version](https://badge.fury.io/py/beatstoch.svg)](https://pypi.org/project/beatstoch/) [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: Unlicense](https://img.shields.io/badge/license-Unlicense-green.svg)](https://unlicense.org/)


⚡ Install in Seconds

uv tool install beatstoch

🎬 Quick Demo

# Generate drums that match any song's BPM
beatstoch generate "Billie Jean" --artist "Michael Jackson"

# Rock beat at 120 BPM
beatstoch generate-bpm 120 --style rock

# Shuffle blues with human feel
beatstoch generate-bpm 85 --style blues --humanize 0.6

# Jazz ride pattern
beatstoch generate-bpm 140 --style jazz

Output: Standard MIDI file ready for any DAW 🎹


🎨 7 Unique Styles

  • House


    Four-on-the-floor, driving hi-hats, snare/clap layers

    EDM · Techno · Minimal

  • Breaks


    Syncopated kicks, complex hats, funky grooves

    Breakbeat · DnB · Hip-hop

  • Rock


    Powerful backbeat, 8th note hats, crash accents

    Rock · Alternative · Metal

  • Blues


    Shuffle feel, ride cymbal, ghost notes

    Blues · 12-bar · Slow rock

  • Indie


    Loose feel, floor tom accents, rimshots

    Indie rock · Lo-fi · Alternative

  • Jazz


    Classic ride pattern, sparse comping, swing

    Jazz · Bebop · Fusion

  • Generic


    Balanced patterns for any genre

    Demos · Experimentation


🧠 Powered by Mathematics

beatstoch doesn't just randomize—it uses psychoacoustic algorithms for patterns that sound natural:

Algorithm Purpose
Golden Ratio Natural spacing and timing
Fibonacci Sequences Probability distribution
Fractal Patterns Self-similar complexity
Psychoacoustic Balancing Perceived naturalness

🎛️ Full Control

beatstoch generate-bpm 128 \
    --style house \           # 7 styles available
    --bars 16 \               # Pattern length
    --meter 4/4 \             # Time signature (2/4, 3/4, 4/4)
    --humanize 0.6 \          # Ghost notes + timing variation
    --groove-intensity 0.8 \  # Swing and feel
    --predictability 0.7      # 1.0=mechanical, 0.0=chaotic

🐍 Python Library

from beatstoch import generate_stochastic_pattern

# Generate a rock beat
midi = generate_stochastic_pattern(
    bpm=120,
    bars=8,
    style="rock",
    humanize=0.5,
    predictability=0.8
)
midi.save("my_beat.mid")

📚 Documentation


🎵 GM Drum Compatible

All patterns use General MIDI standard—works with any DAW, synth, or drum machine:

  • 30+ drum/percussion sounds
  • Kicks, snares, hi-hats, cymbals
  • Toms, percussion, cowbell 🔔

**Ready to make some noise?** [Get Started :material-arrow-right:](user-guide.md){ .md-button .md-button--primary } [View on GitHub :material-github:](https://github.com/james-see/beatstoch){ .md-button }