Turn any array of integers into a fun little melody using the Web Audio API. https://chrisburnell.com/pentatonic/
Find a file
2023-02-02 00:38:28 +00:00
.github add FUNDING 2021-11-26 12:55:38 +00:00
.editorconfig tidy up README; lint JS; bump version 2023-02-01 17:44:55 +00:00
.eslintrc.json tidy up README; lint JS; bump version 2023-02-01 17:44:55 +00:00
.gitignore 🦛 the hippopotamus is no ignoramus 2020-09-25 10:51:19 +01:00
.npmignore fix .npmignore 2023-02-01 17:46:24 +00:00
.prettierrc tidy up README; lint JS; bump version 2023-02-01 17:44:55 +00:00
LICENSE Update LICENSE 2020-09-27 11:31:10 +01:00
package-lock.json tidy up README; lint JS; bump version 2023-02-01 17:44:55 +00:00
package.json fix: add main back to package.json 2023-02-02 00:38:28 +00:00
pentatonic.js normalise notes against key limit 2022-01-24 19:16:27 +00:00
README.md tidy up README; lint JS; bump version 2023-02-01 17:44:55 +00:00

Pentatonic

Turn any array of integers into a fun little melody

What?

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

Why?

Why not?

No, but really though, theres no serious reason for this. Its just fun.

Installation

Usage

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

for (let target of document.querySelectorAll(".pentatonic")) {
    target.addEventListener("click", () => {
        pentatonic(target.dataset.values.split(","))
    })
}

The function takes six parameters:

  1. notes — an array of positive integers (required)
  2. duration — the length of time to play the audio for, represented in milliseconds (default = 4000)
  3. volume — controls the gain of the audio, represented by a 01 range (default = 0.5)
  4. keyStart — the zero-index of the key on a standard keyboard from which the scale should start (default = 29 / C♯3 / D♭3)
  5. keyIntervals — an array of integers which represent half-steps in a loop which composes the desired scale (default = [2, 3, 2, 2, 3] / a pentatonic scale)
  6. keyLimit — represents the highest index in the desired scale by which input is bound by (default = 12)

Contributing

Contributions of all kinds are welcome! Please submit an Issue on GitHub or get in touch with me if youd like to do so.

License

This project is licensed under a CC0 license.