mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 04:28:30 +00:00
cache loaded soundfonts
This commit is contained in:
parent
8bd56d29d6
commit
3986c407ff
@ -1,6 +1,6 @@
|
|||||||
import { getFontBufferSource } from './fontloader.mjs';
|
import { getFontBufferSource } from './fontloader.mjs';
|
||||||
import * as soundfontList from './list.mjs';
|
import * as soundfontList from './list.mjs';
|
||||||
import { loadSoundfont, startPresetNote } from 'sfumato';
|
import { startPresetNote } from 'sfumato';
|
||||||
import './sfumato.mjs';
|
import { loadSoundfont } from './sfumato.mjs';
|
||||||
|
|
||||||
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList };
|
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList };
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import { Pattern } from '@strudel.cycles/core';
|
import { Pattern } from '@strudel.cycles/core';
|
||||||
import { /* loadSoundfont, */ startPresetNote } from 'sfumato';
|
import { loadSoundfont as _loadSoundfont, startPresetNote } from 'sfumato';
|
||||||
|
|
||||||
// TODO: find way to cache loadSoundfont
|
|
||||||
|
|
||||||
Pattern.prototype.soundfont = function (sf, n = 0) {
|
Pattern.prototype.soundfont = function (sf, n = 0) {
|
||||||
return this.onTrigger((t, h, ct) => {
|
return this.onTrigger((t, h, ct) => {
|
||||||
@ -14,3 +12,13 @@ Pattern.prototype.soundfont = function (sf, n = 0) {
|
|||||||
stop(deadline + h.duration);
|
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