npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jmon/algo

v1.2.7

Published

Algorithmic music composition library with generative algorithms, music theory, and format conversion

Readme

jmon/algo

JavaScript music composition toolkit for algorithmic and generative music.

Getting Started

Node.js

We recommend to run jmon/algo in a Observable Notebook Kit environment with Node.js, which you will need to install on your system Node.js will run the code and will allow to install packages with npm.

  1. Make sure that Node.js is installed on your system

Open a terminal and run the following command:

node --version

If the terminal can't find the command, head up to https://nodejs.org/ and install fond out how to install Node.js on your system. If a version number appears, kudos.

  1. Create a folder and cd

Use command lines or your file browser to create a folder for your music project. Copy its path and write cd followed by the path.

cd /path/of/my/project
  1. Install the packages

You'll have to initiate your project and install both @jmon/algo and @observablehq/notebook-kit.

npm init -y
npm install @jmon/algo @observablehq/notebook-kit
  1. Create your notebook

Observable Notebook Kit is a wonderful way to start coding in JavaScript. Create a new html, e.g. index.html, file with your favorite text editor (Zed is light and fast, VSCode is full of features).

<!doctype html>
<notebook>
  <title>My Composition</title>
  <script type="text/markdown">
    A *markdown* **cell** to annotate your `code`.
    
    The following cell loads libraries.
  </script>
  <script type="module" pinned>
    import jm from "@jmon/algo";
    import * as Tone from "npm:tone";
    import verovio from "npm:[email protected]/wasm";
    import { VerovioToolkit } from "npm:[email protected]/esm";
  </script>
  <script type="text/markdown">
    Let's start coding!
  </script>
  <script type="module">
    const melody = jm.theory.harmony.Scale.generate("C", "major").map((p, i) => ({
      pitch: p, duration: 1, time: i, velocity: 0.8
    }));
    const comp = { tempo: 120, tracks: [{ label: "Scale", notes: melody }] };
    display(await jm.score(comp, { verovio, VerovioToolkit }));
    display(await jm.play(comp, { Tone }));
  </script>
</notebook>
  1. Open your notebook

Start a server with:

npx notebooks preview --root .

Servers sounds heavy and complicated, but it's really just allowing you browser to run the files of your local folder. Your terminal will show an unfinished command with a url like http://localhost:5173/. Paste in in a browser and if your notebook is named index.html, it should apear. Else, just head up to http://localhost:5173/my_other_file.html

Each time you update the notebook, your browser updates. Docking the windows helps a lot!

Deno

If you prefer deno to Node.js,

  1. Create deno.json
{
  "nodeModulesDir": "auto",
  "imports": {
    "@jmon/algo": "jsr:@jmon/algo"
  }
}
  1. Create you html notebook (same as above)

  2. Run the notebook

And run deno run -A npm:@observablehq/notebook-kit preview --root .

Userguide

The userguide/ folder on the repository of this project contains interactive HTML notebooks built with Observable Notebook Kit.


**Available Guides:**
- `01-getting-started.html` - JMON format basics
- `02-harmony.html` - Scales, chords, voice leading
- `03-loops.html` - Polyrhythms and loops
- `04-minimalism.html` - Process music (additive, subtractive, tintinnabuli)
- `05-minimalism.html` - Advanced minimalism techniques
- `06-walks.html` - Random walks and Gaussian processes
- `07-fractals.html` - Cellular automata and fractals
- `08-genetic-algorithms.html` - Evolutionary composition
- `09-microtuning.html` - Microtonality and tuning systems
- `live-coding.html` - Live coding environment

## The API

A very light example.

```javascript
import jm from "@jmon/algo";
import * as Tone from "tone";
import verovio from "verovio/wasm";

const melody = [
  { pitch: 60, duration: 1, time: 0, velocity: 0.8 },
  { pitch: 62, duration: 1, time: 1, velocity: 0.8 },
  { pitch: 64, duration: 1, time: 2, velocity: 0.8 }
];

const composition = {
  tempo: 120,
  tracks: [{ label: 'Melody', notes: melody }]
};

// Render notation
const svg = await jm.score(composition, { verovio });

// Play audio
const player = await jm.play(composition, { Tone });

JMON Format

Je JMON format is a music notation as JSON objects:

// A note
{ pitch: 60, duration: 1, time: 0, velocity: 0.8 }

// A track (array of notes)
const track = [
  { pitch: 60, duration: 1, time: 0, velocity: 0.8 },
  { pitch: 62, duration: 1, time: 1, velocity: 0.8 }
];

// A composition
const composition = {
  tempo: 120,
  tracks: [
    { label: 'Melody', notes: track }
  ]
};

Features

Theory (jm.theory.*)

  • Scales, intervals, chords
  • Voice leading and progressions
  • Ornaments and articulations
  • Rhythm generation

Generative (jm.generative.*)

  • Minimalism: Process-based composition (additive, subtractive, tintinnabuli)
  • Random Walks: Markov chains, Brownian motion
  • Fractals: Mandelbrot sets, logistic maps
  • Cellular Automata: Conway's Game of Life, rule 30/110
  • Genetic Algorithms: Evolutionary composition
  • Gaussian Processes: Smooth interpolation (requires @tangent.to/ds)

Analysis (jm.analysis.*)

  • 11+ musical metrics
  • Gini coefficient, syncopation, contour entropy
  • Statistical pattern analysis

Converters (jm.converters.*)

  • MIDI files
  • Tone.js (web audio)
  • Verovio (notation rendering)
  • WAV audio
  • SuperCollider
  • ABC notation

Building

deno task build    # Build ESM and UMD bundles
deno task test     # Run tests

License

GPL-3.0-or-later

Links