Simple Node.js Piano
$ npm i jspianoconst { 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 secondmysheet.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
}
]const { Piano } = require("jspiano");
const piano = new Piano(["C4", "C5"]);
piano.playSheet("./mysheet.json");Available from C0 to C7.
Emitted when a note is pressed! Returns object with note, octave, frequency, duration and time.
piano.on("press", ({ note, duration }) => console.log(note, duration));