mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 05:38:35 +00:00
(squash me) save setting in variable, not store
This commit is contained in:
parent
e3b6884b86
commit
b233c33f56
@ -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'
|
||||
}
|
||||
let defaultSoundfontUrl = 'https://felixroos.github.io/webaudiofontdata/sound';
|
||||
let soundfontUrl = defaultSoundfontUrl;
|
||||
|
||||
export const fontloaderConfigMap = persistentMap('strudel-config-fontloader', defaultFontloaderConfig);
|
||||
|
||||
export function setSoundfontUrl(obj) {
|
||||
fontloaderConfigMap.setKey('soundfontUrl', JSON.stringify(obj));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user