diff --git a/packages/soundfonts/fontloader.mjs b/packages/soundfonts/fontloader.mjs index 27f1875a7..43798b577 100644 --- a/packages/soundfonts/fontloader.mjs +++ b/packages/soundfonts/fontloader.mjs @@ -1,4 +1,3 @@ -import { persistentMap } from '@nanostores/persistent'; import { noteToMidi, freqToMidi, getSoundIndex } from '@strudel/core'; import { getAudioContext, @@ -10,18 +9,11 @@ import { } from '@strudel/webaudio'; import gm from './gm.mjs'; -export const defaultFontloaderConfig = { - soundfontUrl: 'https://felixroos.github.io/webaudiofontdata/sound' -} - -export const fontloaderConfigMap = persistentMap('strudel-config-fontloader', defaultFontloaderConfig); - -export function setSoundfontUrl(obj) { - fontloaderConfigMap.setKey('soundfontUrl', JSON.stringify(obj)); -} +let defaultSoundfontUrl = 'https://felixroos.github.io/webaudiofontdata/sound' +let soundfontUrl = defaultSoundfontUrl -export function getSoundfontUrl() { - return JSON.parse(fontloaderConfigMap.get().soundfontUrl); +export function setSoundfontUrl(value) { + soundfontUrl = value } let loadCache = {}; @@ -31,7 +23,7 @@ async function loadFont(name) { } const load = async () => { // TODO: make soundfont source configurable - const url = `${getSoundfontUrl()}/${name}.js`; + const url = `${soundfontUrl}/${name}.js`; const preset = await fetch(url).then((res) => res.text()); let [_, data] = preset.split('={'); return eval('{' + data);