1.0.3 • Published 5 years ago
jspiano v1.0.3
Piano
Simple Node.js Piano
Installing
$ npm i jspianoExample
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 secondSheets
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));
