use velocity in tone + midi + defaultSynth

This commit is contained in:
Felix Roos 2022-03-06 14:39:33 +01:00
parent fbc629c6da
commit 58e8e311a3
3 changed files with 19 additions and 16 deletions

View file

@ -61,14 +61,14 @@ function useRepl({ tune, defaultSynth, autolink = true, onEvent, onDraw }: any)
(time, event) => {
try {
onEvent?.(event);
const { onTrigger } = event.context;
const { onTrigger, velocity } = event.context;
if (!onTrigger) {
const note = event.value;
if (!isNote(note)) {
throw new Error('not a note: ' + note);
}
if (defaultSynth) {
defaultSynth.triggerAttackRelease(note, event.duration, time);
defaultSynth.triggerAttackRelease(note, event.duration, time, velocity);
} else {
throw new Error('no defaultSynth passed to useRepl.');
}