add sfumato soundfont player
This commit is contained in:
parent
467b3db824
commit
8bd56d29d6
4 changed files with 51 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { getFontBufferSource } from './fontloader.mjs';
|
||||
import * as soundfontList from './list.mjs';
|
||||
import { loadSoundfont, startPresetNote } from 'sfumato';
|
||||
import './sfumato.mjs';
|
||||
|
||||
globalThis.getFontBufferSource = getFontBufferSource;
|
||||
globalThis.soundfontList = soundfontList;
|
||||
globalThis.soundfontList = soundfontList;
|
||||
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList };
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
"homepage": "https://github.com/tidalcycles/strudel#readme",
|
||||
"dependencies": {
|
||||
"@strudel.cycles/core": "*",
|
||||
"@strudel.cycles/webaudio": "^0.1.4"
|
||||
"@strudel.cycles/webaudio": "^0.1.4",
|
||||
"sfumato": "^0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-fetch": "^3.2.6"
|
||||
|
|
|
|||
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