mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 21:58:37 +00:00
cache loaded soundfonts
This commit is contained in:
parent
8bd56d29d6
commit
3986c407ff
@ -1,6 +1,6 @@
|
||||
import { getFontBufferSource } from './fontloader.mjs';
|
||||
import * as soundfontList from './list.mjs';
|
||||
import { loadSoundfont, startPresetNote } from 'sfumato';
|
||||
import './sfumato.mjs';
|
||||
import { startPresetNote } from 'sfumato';
|
||||
import { loadSoundfont } from './sfumato.mjs';
|
||||
|
||||
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList };
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { Pattern } from '@strudel.cycles/core';
|
||||
import { /* loadSoundfont, */ startPresetNote } from 'sfumato';
|
||||
|
||||
// TODO: find way to cache loadSoundfont
|
||||
import { loadSoundfont as _loadSoundfont, startPresetNote } from 'sfumato';
|
||||
|
||||
Pattern.prototype.soundfont = function (sf, n = 0) {
|
||||
return this.onTrigger((t, h, ct) => {
|
||||
@ -14,3 +12,13 @@ Pattern.prototype.soundfont = function (sf, n = 0) {
|
||||
stop(deadline + h.duration);
|
||||
});
|
||||
};
|
||||
|
||||
const soundfontCache = new Map();
|
||||
export function loadSoundfont(url) {
|
||||
if (soundfontCache.get(url)) {
|
||||
return soundfontCache.get(url);
|
||||
}
|
||||
const sf = _loadSoundfont(url);
|
||||
soundfontCache.set(url, sf);
|
||||
return sf;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user