Skip to main content

Code-first beat making in Python — sample-driven, config-driven, no DAW required

Project description

beat-engine

CI PyPI version Python versions License: MIT Code style: ruff Gitmoji

Code-first beat making in Python. Bring your own samples (WAV files or SF2 soundfonts), describe a song in TOML or a Python dict, render to WAV / stems / MIDI. No DAW required.

Status

0.1.0 — alpha. The audio pipeline (numpy float32 + pedalboard direct, no pydub, no tempfile round-trips) is complete and tested. The lib already produces well-mixed beats from a config alone, but several "modern pro" features are explicitly deferred to 0.2. Expect breaking config changes between 0.x versions.

Working today

  • Sample-driven rendering — WAV one-shots, multisample directories, SF2 soundfonts.
  • 16 scales, 9 melody contour shapes, A-A' motif sequencer with cross-bar continuity.
  • Drum patterns with energy-based switching, accents, ghost notes, fills, ratchets, stutters, drops.
  • Voice-leading, chord inversions, chromatic bass approaches.
  • Per-instrument Pedalboard FX (Reverb, Compressor, Chorus, Delay, Distortion, Bitcrush, Highpass, Lowpass, PeakFilter, Limiter), sends, sidechain ducking, saturation, tape wobble, auto-pan, stereo width.
  • Section dynamics: fade-in / fade-out, crossfade, crescendo / decrescendo, key shift, tape stop, vinyl crackle.
  • Master chain: bus compressor + brick-wall limiter, optional LUFS-target normalize.
  • WAV / stems / MIDI export.

Deferred to 0.2

  • Phase-vocoder pitch shift (sustained melodic notes currently shorten with the tape-trick shift).
  • Automation envelopes — filter sweeps into the hook, opening reverb tails on the drop.
  • Procedural generators: noise_riser, sine_sub, impact — config-only, no samples needed.
  • Real 808 glide / portamento.
  • Tempo curves and per-section BPM.
  • Per-section per-instrument FX overrides.

A 30-second demo render lives in examples/demo_beat.pypython examples/demo_beat.py writes demo_beat.wav from synthetic samples.

Install

pip install beat-engine

# Optional extras:
pip install beat-engine[sf2]        # SoundFont (.sf2) playback via FluidSynth
pip install beat-engine[loudness]   # LUFS-target master normalization

Quick start

from beat_engine import quick_render

quick_render({
    "song": {"bpm": 85, "title": "My Beat", "key": "C minor"},
    "sections": [
        {"name": "verse", "bars": 4, "energy": 0.5},
        {"name": "hook",  "bars": 4, "energy": 0.8},
    ],
    "base": {
        "chord_progression": [["C4", "D#4", "G4"], ["G#3", "C4", "D#4"]],
        "instruments": {
            "kick":  {"sample": "samples/kick.wav",  "pattern": "x---x---x---x---"},
            "snare": {"sample": "samples/snare.wav", "pattern": "----x-------x---", "volume_db": -3},
            "hat":   {"sample": "samples/hihat.wav", "pattern": "x-x-x-x-x-x-x-x-", "volume_db": -10},
            "bass":  {"sample": "samples/bass_C2.wav", "source_note": "C2", "bass_profile": "anchor"},
        },
    },
}, output="my_beat.wav")

CLI

beat-engine render   songs/my_song              # full mix WAV
beat-engine stems    songs/my_song              # one WAV per instrument
beat-engine midi     songs/my_song              # Standard MIDI File
beat-engine validate songs/my_song              # config lint

Sound sources

You bring your own samples — beat-engine ships no audio.

Mode Config keys Notes
Single sample sample + source_note One WAV pitch-shifted per note (tape-speed shift, changes duration)
Multisample dir sample_dir Picks closest note from a directory of note_velocity_rr.wav files
SF2 soundfont sf2 + sf2_preset + sf2_bank FluidSynth rendering, requires [sf2] extra

Features

Sequencing: 16-step drum patterns, energy-based pattern switching, accent patterns (H/M/m/l), ghost notes, fills, ratchets, stutters, drops, swing, per-instrument groove templates (mpc/lazy/push/funk), velocity curves (linear/exponential/logarithmic/soft/hard), humanize, laid-back timing, hit probability.

Harmony: 16 scales (major, minor, modes, blues, pentatonics, exotic), voice-leading, chord inversions, chromatic bass approaches, key shifts per section, harmony layer (counter-melody from a source instrument).

Melody: auto-generation from scale + contour (arch/ascending/descending/wave/flat/valley/zigzag/random_walk/stairs) + density buckets, with chord-tone snapping on strong beats, A-A' motif sequencing, cross-bar continuity, manual step-list melodies.

Mixing: per-instrument FX (Pedalboard) — Reverb / Compressor / Chorus / Delay / Distortion / Bitcrush / Highpass / Lowpass / PeakFilter / Limiter — plus reverb/chorus/delay sends, tempo-synced delay, sidechain ducking, saturation (tanh), tape wobble, auto-pan LFO, stereo width (mid/side), per-instrument pan and gain.

Song-level: intro fade-in, outro fade-out, section crossfades, crescendo / decrescendo, key shifts, tape-stop outro, vinyl crackle.

Master chain: bus compressor + brick-wall Limiter. Optional LUFS-target normalization (target_lufs in config) when pyloudnorm is installed.

Export: 24-bit WAV (full mix), per-instrument stems, Standard MIDI File (Type 1).

Design

beat-engine is a pure-Python lib that delegates DSP to native code:

  • Audio buffers: numpy.ndarray shape (num_samples, 2), float32, 44.1 kHz throughout.
  • Effects: pedalboard (JUCE C++) called directly on the in-memory buffers.
  • I/O: soundfile (libsndfile).
  • SF2: pyfluidsynth (FluidSynth C library).

There is no pydub and no tempfile round-tripping for FX. The musical logic (sequencing, melody generation, MIDI export) is pure Python and stateless where it can be.

Project

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beat_engine-0.1.0.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beat_engine-0.1.0-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file beat_engine-0.1.0.tar.gz.

File metadata

  • Download URL: beat_engine-0.1.0.tar.gz
  • Upload date:
  • Size: 49.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for beat_engine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2e042919407dee44b9228c1fccd02b3644d34f9ebbdcac8c144d548a1bdc2c57
MD5 d05ae7d08f9a348ecb5ac07edc9fba4b
BLAKE2b-256 ade810ed3202b50ece16261fe8f09e406d6799e853792fd95ce61c2748040e52

See more details on using hashes here.

Provenance

The following attestation bundles were made for beat_engine-0.1.0.tar.gz:

Publisher: release.yml on hugocharels/beat-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file beat_engine-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: beat_engine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for beat_engine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f08e720aaa05a79984599eb011819aea83242d04a0f1670fdec809ccfda7eab
MD5 303ea862d530520093eb9e3412936259
BLAKE2b-256 6247f9062d31196718fb8cc922d0d322caeae62835411705873e056a1f4c9546

See more details on using hashes here.

Provenance

The following attestation bundles were made for beat_engine-0.1.0-py3-none-any.whl:

Publisher: release.yml on hugocharels/beat-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page