Do you want to build CircuitPython MIDI drum sequencer? Maybe one like this (Lego style), or like this (plaintext style)? To play sounds, you'll need a MIDI synthesizer or sampler. But, with all the sampler and synth options, which one should you pick? To start with a simple browser-based drum synth, you could try web-midi-drumkit.
Quick Start
To try it out, connect a USB MIDI controller or sequencer to your computer and open the web-midi-drumkit demo page in Chrome (Web MIDI is relatively new, and not all browsers support it). You'll need to click the "Unmute Sound" button and probably also answer a security prompt to allow MIDI access.
Set your MIDI controller or sequencer to send notes on channel 10 using the following note mapping:
| MIDI Note | Note Name | Drum Sound |
|---|---|---|
| 51 | D#3 | Ride Cymbal |
| 49 | C#3 | Crash Cymbal |
| 48 | C3 | Tom 1 (high) |
| 46 | A#2 | Hi-hat (open) |
| 45 | A2 | Tom 2 (low) |
| 43 | G2 | Tom 3 (floor) |
| 42 | F#2 | Hi-hat (closed) |
| 38 | D2 | Snare |
| 36 | C2 | Kick |
Technical Details
To see how the drum synth works, you can read my code on GitHub. The important files and directories are:
-
index.htmlhas HTML that includes SVG paths for the drum pad silhouettes and CSS rules that control color changes for the activity indicators -
main.jshas a JavaScript module that sets up all the event handling and logic to listen for MIDI events, play samples, and update the activity indicators (by changing CSS classes) -
samples/has FLAC format drum sample files
To learn more about HTML, CSS, SVG, and Javascript web APIs, I highly recommend Mozilla's MDN Web Docs, including:
- Web MIDI API
- Web Audio API
- Web audio codec guide (includes playback latency estimates for different audio file types)
- JavaScript
- Getting started with HTML
- CSS: Cascading Style Sheets
- SVG: Scalable Vector Graphics
This page (Web MIDI Drum Synth) was last updated on June 12, 2024.