add sfumato soundfont player
This commit is contained in:
parent
467b3db824
commit
8bd56d29d6
4 changed files with 51 additions and 6 deletions
16
packages/soundfonts/sfumato.mjs
Normal file
16
packages/soundfonts/sfumato.mjs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { Pattern } from '@strudel.cycles/core';
|
||||
import { /* loadSoundfont, */ startPresetNote } from 'sfumato';
|
||||
|
||||
// TODO: find way to cache loadSoundfont
|
||||
|
||||
Pattern.prototype.soundfont = function (sf, n = 0) {
|
||||
return this.onTrigger((t, h, ct) => {
|
||||
const ctx = getAudioContext();
|
||||
const note = getPlayableNoteValue(h);
|
||||
const preset = sf.presets[n % sf.presets.length];
|
||||
const deadline = ctx.currentTime + t - ct;
|
||||
const args = [ctx, preset, toMidi(note), deadline];
|
||||
const stop = startPresetNote(...args);
|
||||
stop(deadline + h.duration);
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue