use velocity in tone + midi + defaultSynth
This commit is contained in:
parent
fbc629c6da
commit
58e8e311a3
3 changed files with 19 additions and 16 deletions
|
|
@ -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.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue