JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q19622F
  • License MIT

Simple Node.js Piano

Package Exports

  • jspiano

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jspiano) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Piano

Simple Node.js Piano

Installing

$ npm i jspiano

Example

const { Piano } = require("jspiano");
const piano = new Piano("C4"); // load piano with octave C4

piano.press("C#", "C4", 1000); // press C# of octave C4 for 1 second

Sheets

Sheet format

mysheet.json

[
    {
        "note": "C",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "D",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "E",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "F",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "G",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "A",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "B",
        "octave": "C4",
        "duration": 1000
    },
    {
        "note": "C",
        "octave": "C5",
        "duration": 1000
    }
]

Load Sheets

const { Piano } = require("jspiano");
const piano = new Piano(["C4", "C5"]);

piano.playSheet("./mysheet.json");

Octaves

Available from C0 to C7.

Events

press

Emitted when a note is pressed! Returns object with note, octave, frequency, duration and time.

piano.on("press", ({ note, duration }) => console.log(note, duration));

Preview

video

Join my discord