Pentatonic v0.1.2

Turn any array of integers into a fun little melody.
There are 1 star-gazers on GitHub and it was downloaded 73 times in the last month on npm.

A snippet of a C Major Pentatonic scale.

Hey, psst!… You can jump straight down to the examples!


Pentatonic is a small JavaScript file that will play music generated from an array of integers from anywhere in your DOM.


Why not? No, but really though, there’s no serious reason for this. It’s just fun.


Yoink it from npm:

npm install @chrisburnell/pentatonic

You can also just download it directly from GitHub:


pentatonic.js gives you a function, pentatonic() to use, like so:

document.querySelectorAll(".pentatonic").forEach(target => {
target.addEventListener("click", () => {

The function takes six parameters:

See array of positive integers
duration4000 (default)the length of time to play the audio for, represented in milliseconds
volume0.5 (default)controls the *gain* of the audio, represented by a 0–1 range
keyStart29 / C♯3 / D♭3 (default)the zero-index of the key on a standard keyboard from which the scale should start
keyIntervals[2, 2, 3, 2, 3] (default)an array of integers which represent half-steps in a loop which composes the desired scale
keyLimit12 (default)represents the highest index in the desired scale by which notes are bound by


Type some numbers in the input field below and a playable sparkline will be built!