danigb / smplr

A web audio sampler instrument
https://danigb.github.io/smplr/
186 stars 19 forks source link

Or schedule events at a given time #7

Closed AlanPaine closed 1 year ago

AlanPaine commented 1 year ago

Here's how to schedule activities at a given time, just like soundfont-player: soundFont.schedule(0, [ { note: key, duration: lengthInMs / 1000, gain: sampleVolume * this.GainMultiplier }, ]);

AlanPaine commented 1 year ago

@danigb Hello, are you there

danigb commented 1 year ago

To schedule notes in time, use the time option of the start function: https://github.com/danigb/smplr#schedule-notes

AlanPaine commented 1 year ago

The important thing is how am I going to set the gain at the start

danigb commented 1 year ago

With the velocity param. 0 means gain = 0. 127 means gain = 1

piano.start({ note: "C4", velocity: 80, time: 5, duration: 1 });