Rhythm808

The Rhythm808 is an analog drum machine with sixteen sounds, one circuit per pad, inspired by the Roland TR-808 Rhythm Composer. Every drum sound is generated by analog-style circuitry: bridged-T resonators, filtered noise bursts, and a six-oscillator metallic bank for cymbals and hats.

import audioinstruments._rack.adapter as adapter

inst = adapter.create(48000, voice="rhythm808")  # 16 voices, 1 per sound
audio_out.play(inst.output)
inst.program_change(0)                          # Classic
inst.note_on(36, 127)                           # Accented Bass Drum
inst.note_on(38, 100)                           # Snare Drum

Sounds and circuits

You play sixteen distinct drum circuits, each mapped to standard General MIDI percussion keys:

voice

sound

keys

panel controls

0

bass drum (BD)

35, 36

level, tone, decay

1

rim shot (RS)

37

level

2

snare drum (SD)

38, 40

level, tone, snappy

3

hand clap (CP)

39

level

4

closed hi-hat (CH)

42, 44

level

5

open hi-hat (OH)

46

level, decay

6

low tom (LT)

41, 43

level, tuning

7

mid tom (MT)

45, 47

level, tuning

8

high tom (HT)

48, 50

level, tuning

9

cymbal (CY)

49, 51, 57

level, tone, decay

10

cowbell (CB)

56

level

11

high conga (HC)

62

level (tuning shared with HT)

12

mid conga (MC)

63

level (tuning shared with MT)

13

low conga (LC)

64

level (tuning shared with LT)

14

claves (CL)

75

level

15

maracas (MA)

70

level

The bass drum is a bridged-T resonant filter tuned around 52.7 Hz. It drops by about 230 cents over its first 35 ms as the membrane tightens and releases. bd_tone shapes the initial strike click with a low-pass filter (300 Hz to 3 kHz), and bd_decay extends the resonance from a punchy 80 ms to over 1.5 seconds of pure, DC-free sub-bass boom.

The snare drum combines two bridged-T resonant body tones near 238 and 476 Hz with high-passed white noise. sd_tone balances the low body against the high ring, while sd_snappy sets the level of the snare wires.

The toms and congas use bridged-T oscillators with downward pitch bends. Toms (LT 80-100 Hz, MT 120-160 Hz, HT 165-220 Hz) incorporate pink noise in the strike for membrane bite; tuning sweeps each range. Congas (LC 165-220 Hz, MC 250-310 Hz, HC 370-455 Hz) are higher-pitched and pure sine tones, sharing their tuning controls with the corresponding toms.

The rim shot combines two short resonant pulses near 500 Hz and 1.7 kHz through a high-pass filter for a wooden crack. The claves ring at 2.5 kHz with a clean, fast decay (25 ms). The maracas produce short, softened bursts of high-passed noise.

The hand clap routes white noise through a 1.1 kHz band-pass filter, fired by a multi-burst envelope with three sharp spikes 10 ms apart before letting a diffuse tail ring out.

The cowbell pairs two square waves at 540 and 800 Hz through a 2.6 kHz band-pass filter, decaying in two distinct stages: a fast 15 ms drop followed by a 300 ms resonant tail.

The metallic bank drives the closed hat, open hat, and cymbal from six unrelated square-wave oscillators (205.3, 304.4, 369.6, 522.7, 540, and 800 Hz). The hi-hats filter the sum through a 7.5 kHz band-pass and high-pass network. The cymbal splits the sound into lower (3.4 kHz) and upper (7.1 kHz) bands, balanced by cy_tone, with cy_decay stretching from 300 ms to over 3 seconds.

The choke and additions

On the original instrument, toms and congas (as well as rim shot and claves, clap and maracas) shared circuits selected by panel switches. In Rhythm808, every sound has its own dedicated voice in the pool, allowing all sixteen sounds to trigger simultaneously.

The hi-hats share a choke group (CHOKE = ((4, 5),)): triggering a closed hi-hat immediately cuts off a ringing open hi-hat over a single block fade, matching the physical behavior of acoustic and analog hats.

Triggering a pad while its voice is still sounding re-pings the resonant filter smoothly without an audible click or phase jump. Because drum hits are one-shot, voices respond strictly to the rising edge of the gate.

Accent and output

MIDI velocity serves as the accent. The accent parameter (0 to 10, default 5) sets the dynamic sensitivity: at 0 all hits have uniform volume, while at 10 soft hits (velocity 40) sit 18 dB below accented strikes (velocity 127). Accent also brightens the tone of the bass drum click, snare snap, and hand clap.

The output section routes the mono voice sum through volume (0 to 10, default 7) and a soft ceiling tanh saturator. This keeps sixteen simultaneous accented hits from hard-clipping the digital rails. inst.latency_samples is 0.

Patches and macros

There are six factory presets:

  • Classic: all controls at 5, replicating the out-of-the-box instrument.

  • Long Boom: maximum kick decay, low tone, tuned-down toms, and snappy snare.

  • Tight: short kick and dry hats for electro-funk.

  • Electro: boosted kick tone and decay with prominent cowbell and clap.

  • Soft: low accent and muted tones for quiet rhythm box accompaniment.

  • Latin: prominent congas, claves, maracas, and high-tuned toms.

The eight macros control bd_decay, bd_tone, sd_tone, sd_snappy, oh_decay, cy_decay, accent, and volume.

examples/rhythm808_demo.py demonstrates all six presets across 30 bars of classic patterns, writing wav_exports/rhythm808_demo.wav.

What it costs

examples/poly_bench.py rhythm808 benchmarks all sixteen sounds ringing at once (struck again every four buffers). The times are milliseconds per 1024 frames of audio (21.3 ms is real time), best of two runs:

block

CPython ms

factor

MicroPython ms

factor

64

26.57

0.80

19.93

1.07

128 (default)

16.45

1.30

12.90

1.65

256

11.07

1.93

10.83

1.97

At the default 128-frame block, all sixteen sounds at once run faster than real time on both interpreters. At 64 frames CPython falls just short with every sound sounding at once; a kit that is mostly idle costs far less, because a sound that has gone quiet parks and takes no time (0.13 ms per buffer on CPython and 0.4 ms on MicroPython with nothing playing).