Package Exports
- @ondas/piano
- @ondas/piano/dist/index.js
- @ondas/piano/dist/index.mjs
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 (@ondas/piano) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Piano
A self-container mono-sample piano
A sampled piano. By default is uses Steinway samples with 4 velocity layers from SplendidGrandPiano
import Piano from "@ondas/piano";
const piano = new Piano(new AudioContext());
await piano.ready();
piano.start("C4");import Piano from "@ondas/piano";
const piano = new Piano(new AudioContext());
// Wait until the audio is loaded
await piano.ready();
// Start and stop
const stopNote = piano.start("C4");
stopNote();
// Schedule
piano.start({ name: "C4", time: audioContext.currentTime });Install
npm i @ondas/pianoUsage
Start and stop notes
Start function accepts note name, midi number or object:
piano.start("C4");
piano.start(60);
piano.start({ note: "C4" });
piano.start({ midi: "C4" });Start function returns a stop function:
const stopNote = piano.start("C4");
stopNote();You can stop all sounding notes at once:
["D4", "F4", "A4"].map(piano.start);
piano.stop();Schedule
You can pass an optional time to note object:
const now = context.currentTime;
piano.start({ note: "C4", time: now });
piano.start({ note: "E4", time: now + 0.5 });
piano.start({ note: "G4", time: now + 1 });