CLI tool
scribbletune/scribbletune avatar
scribbletune/scribbletune

Scribbletune: Generating MIDI Files from Pattern Strings in JavaScript

Create music with JavaScript

3,776 stars237 forksTypeScriptMIT

At a glance

What is it?
Scribbletune turns short rhythm strings like x-x- into MIDI files or live browser playback through Tone.js. It is a small library with a CLI, and its main constraint is that it stops at note generation.
Who is it for?
Adopt Scribbletune if you want to script note generation in Node or in a browser page and hand the result to a DAW or to Tone.js; the pattern language and the --riff, --chord and --arp CLI modes cover a lot of ground with very little code. Skip it if you need a full DAW, an audio renderer or a GUI, because the library emits note data and the browser entry point depends on Tone.js for sound.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 45 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 3, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What Scribbletune Actually Generates

Scribbletune is a note generator. You describe a rhythm as a string and a set of pitches as an array or a scale name, and the library produces MIDI data. In Node that data can be written to a .mid file; in the browser it can be handed to Tone.js for playback. The README states the goal plainly: use simple strings and arrays to craft rhythms, melodies and chord progressions, then export MIDI or play them live.

The audience is JavaScript and TypeScript developers who want musical output without learning a DAW scripting language. A backend developer who wants a drum loop for a game prototype, or a frontend developer who wants a page that plays a chord progression, is the target user. Someone who wants to record audio, mix tracks or design synth patches is not, because nothing in the library does those things.

The Pattern String Is the Whole Interface

Everything in Scribbletune starts from a pattern string. The README gives the mapping directly: x is a note on, - is a rest, _ sustains the previous note, R picks a random note from a randomNotes pool, and square brackets subdivide a step, so [xx] places two notes inside one beat. A basic kick pattern is written as "x---x---x-x-x---".

That notation is the library's real design decision. Instead of a step sequencer object or a piano roll data structure, you get a compact string that is easy to type, easy to repeat and easy to generate programmatically. The cost is that complex rhythms become dense strings, and the README itself warns that patterns containing [ and ] must be quoted in the shell, or the shell will interpret the brackets before Scribbletune sees them.

Installing Scribbletune and Writing a First MIDI File

The README gives one install command and two entry points. Install the package locally with npm, then either call the library from a script or run the bundled CLI through npx.

bash
npm install scribbletune

For a script, import scale, clip and midi, build a note pool from a scale name, wrap it in a clip with a pattern, and write the result to a file. The README's Node example uses an eight-step pattern and writes c-major.mid.

js
import { scale, clip, midi } from "scribbletune";

const notes = scale("C4 major");
const c = clip({ notes, pattern: "x".repeat(8) });

midi(c, "c-major.mid");

Run that file with node and a .mid appears in the working directory. The README says to open it in Ableton Live, GarageBand, Logic, or any DAW. If you prefer the terminal, install the CLI globally and use the riff mode, which takes a root note, a mode, a pattern and an output file.

bash
npm install -g scribbletune
scribbletune --riff C3 phrygian x-xRx_RR --outfile riff.mid

The CLI also exposes --chord and --arp modes. Chord and arp progressions accept degree digits such as 1645, roman numerals such as "I IV vi V", comma-separated numerals, the literal word random, or explicit chord names such as CM-FM-Am-GM. The README notes that with explicit chord names the root and mode arguments are ignored.

Riff Motifs, Auto-Fit and the --order Flag

The --style flag is the most interesting CLI feature and the one most likely to surprise. Passing --style AABC with a pattern creates four sections, one per letter, and repeated letters reuse the exact same generated section, including any random R choices. That means an A section is genuinely identical both times, not regenerated and not varied. If you expected a motif system that varies repeats, this is not it.

Auto-fit is the other behaviour worth knowing. The README says it is enabled by default, so a single x in an arp pattern expands to the full generated arp length; --no-fit-pattern disables it when you want a short clip instead. There is also --order, which sets the note order inside each arpeggiated chord. One-based order such as 1234 or 2143 is recommended, and zero-based order such as 0123 is still accepted for backward compatibility. That dual scheme is a compatibility concession, and it means a typo in the order string can silently produce a different arpeggio rather than an error.

Where Scribbletune Stops

The library produces note events. It does not produce sound on its own. In the browser, the /browser entry point adds Session, Channel and live clip support on top of Tone.js, and the README's example calls Tone.start() and Tone.Transport.start() before starting a clip. Tone.js is therefore a runtime dependency for browser playback, not an optional extra, and the README does not document a fallback if you would rather use the Web Audio API directly.

There is a second boundary in the CLI. The --bpm option exists, but the README itself adds the caveat that your DAW may or may not support it. Tempo embedded in a MIDI file is not universally honoured, so a project that depends on a specific tempo should verify it in the target DAW rather than assume the flag settles the matter. Nothing in the README suggests the library handles automation, mixing or effects.

Scribbletune or Tone.js Alone

The obvious alternative is Tone.js by itself. Tone.js is a Web Audio framework: it schedules synths, samples and transport, and it is what Scribbletune's browser entry point builds on. The difference in approach is where the musical structure lives. With Tone.js alone you write a Tone.Part or a Tone.Sequence and specify each event; with Scribbletune you write a pattern string and a note pool and let the library expand them into events.

If your project is a live instrument, a synth patch or anything where scheduling precision and audio graph control matter more than shorthand, Tone.js directly is the better fit, because Scribbletune adds an abstraction you would then work around. If your project is generating note data from a script or a server, Scribbletune's string notation and its MIDI export are the part Tone.js does not give you. The two are not really competitors so much as different layers, and the /browser subpath makes that explicit.

Licence, Maintenance and Upgrade Cost

The licence is MIT, and the repository ships a LICENSE.txt at the top level. MIT is permissive: it allows commercial and closed-source use with attribution and without copyleft obligations. This is a description of the licence text, not legal advice, and anyone embedding the library in a product should read LICENSE.txt themselves.

The last push to the default branch was on 2026-08-20, and the repository is not archived. The release history is uneven rather than steady: v5.0.1 in September 2022, v5.0.2 in January 2024, and v5.5.4 in February 2026. That pattern suggests bursts of work rather than a continuous cadence, which matters if you need a fix turned around quickly. Note also that the package.json in the repository declares version 5.5.5 while the newest release listed is v5.5.4, so the published tarball and the repository state may not be identical at any given moment.

Upgrade cost is low in one respect and worth checking in another. The runtime dependency list is short: @scribbletune/midi and harmonics. The build is tsup, tests run under vitest, and linting is biome, so contributing requires no unusual toolchain. On the other hand, the CLI keeps zero-based --order values for backward compatibility while recommending one-based values, which is the kind of dual convention that tends to persist. Pinning a version and reading the release notes before moving is the cheap precaution.

Editorial conclusion

Adopt Scribbletune if you want to script note generation in Node or in a browser page and hand the result to a DAW or to Tone.js; the pattern language and the --riff, --chord and --arp CLI modes cover a lot of ground with very little code. Skip it if you need a full DAW, an audio renderer or a GUI, because the library emits note data and the browser entry point depends on Tone.js for sound. Before committing, run npm install scribbletune and check that the exported names match your version, since the published package.json reports 5.5.5 while the newest release listed is v5.5.4.

Frequently asked questions

What is Scribbletune?

It is a JavaScript and TypeScript library, plus a CLI, for creating music from pattern strings and note arrays. It exports MIDI files in Node and can play clips live in the browser through Tone.js.

How do I install Scribbletune?

The README gives npm install scribbletune for a local install, or npm install -g scribbletune for the global CLI. With a local install, the command is npx scribbletune.

Does Scribbletune produce audio?

No. It generates note data and MIDI files. In the browser, the /browser entry point adds Session, Channel and live clip support on top of Tone.js, so Tone.js handles the sound.

What do the characters in a Scribbletune pattern mean?

The README maps x to a note on, - to a rest, _ to sustaining the previous note, R to a random note from the randomNotes pool, and square brackets to subdivision, so [xx] puts two notes in one beat.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. scribbletune/scribbletune on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/scribbletune-scribbletune.svg)](https://hysenlabs.com/projects/scribbletune-scribbletune)