danigb / soundfont-player

Quick soundfont loader and player for browser
MIT License
453 stars 60 forks source link

How to play a note and specify its velocity? #79

Open a1exwang opened 3 years ago

fheyen commented 3 years ago

I agree that this would be a nice feature, especially since I did not find any way to implement this with oscillators or other libraries.

abulka commented 2 years ago

Passing velocity to the gain option seems to work e.g.

  let envelope = tone.play(
    note,
    when,
    {
      gain: velocity,
      sustain: 3.5,
    })