A command-line tool to convert drum pattern text files (.pat) to MIDI files. Based on the file format from the drum-patterns repository.
Convert a single pattern file to MIDI:
deno --allow-read --allow-write pat2midi.ts examples/example.pat
Convert a pattern file with custom velocity settings:
deno --allow-read --allow-write pat2midi.ts examples/named.pat --accentVelocity 100 --normalVelocity 80
Convert all pattern files in a directory:
deno --allow-read --allow-write pat2midi.ts examples
Debug mode outputs MIDI file contents as JSON:
deno --allow-read --allow-write pat2midi.ts examples/example.pat --debug
Pattern files use a simple text format where each line represents a drum instrument:
42 x---x---x---x---
38 ----x-------x---
36 x-------x-x-----
AC ----x-------x---
Each line contains:
- A MIDI note number or drum name (e.g., 42 or CH)
- A pattern using 'x' (hit) and '-' (silence)
- Optional 'AC' line defining accents
Standard drum names can replace MIDI numbers:
CH --x---x---x--xx-
CP ----x-------x---
BD x---x---x---x---
AC ----x-------x-x-
Name | Description | MIDI Note |
---|---|---|
BD | Bass Drum | 36 |
RS | Rim Shot | 37 |
SD | Snare Drum | 38 |
CP | Clap | 39 |
CH | Closed Hi-hat | 42 |
LT | Low Tom | 43 |
OH | Open Hi-hat | 46 |
MT | Mid Tom | 47 |
CY | Crash Cymbal | 49 |
HT | High Tom | 50 |
CB | Cowbell | 56 |
Inspired by drum-machine-patterns, drum-patterns and René-Pierre Bardet's book 200 Drum Machine Patterns. Created to provide ready-to-use MIDI drum patterns.