mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 12: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 { noteToMidi, freqToMidi, getSoundIndex } from '@strudel/core';
|
||||||
import {
|
import {
|
||||||
getAudioContext,
|
getAudioContext,
|
||||||
@ -10,18 +9,11 @@ import {
|
|||||||
} from '@strudel/webaudio';
|
} from '@strudel/webaudio';
|
||||||
import gm from './gm.mjs';
|
import gm from './gm.mjs';
|
||||||
|
|
||||||
export const defaultFontloaderConfig = {
|
let defaultSoundfontUrl = 'https://felixroos.github.io/webaudiofontdata/sound';
|
||||||
soundfontUrl: 'https://felixroos.github.io/webaudiofontdata/sound'
|
let soundfontUrl = defaultSoundfontUrl;
|
||||||
}
|
|
||||||
|
|
||||||
export const fontloaderConfigMap = persistentMap('strudel-config-fontloader', defaultFontloaderConfig);
|
export function setSoundfontUrl(value) {
|
||||||
|
soundfontUrl = value;
|
||||||
export function setSoundfontUrl(obj) {
|
|
||||||
fontloaderConfigMap.setKey('soundfontUrl', JSON.stringify(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getSoundfontUrl() {
|
|
||||||
return JSON.parse(fontloaderConfigMap.get().soundfontUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadCache = {};
|
let loadCache = {};
|
||||||
@ -31,7 +23,7 @@ async function loadFont(name) {
|
|||||||
}
|
}
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
// TODO: make soundfont source configurable
|
// TODO: make soundfont source configurable
|
||||||
const url = `${getSoundfontUrl()}/${name}.js`;
|
const url = `${soundfontUrl}/${name}.js`;
|
||||||
const preset = await fetch(url).then((res) => res.text());
|
const preset = await fetch(url).then((res) => res.text());
|
||||||
let [_, data] = preset.split('={');
|
let [_, data] = preset.split('={');
|
||||||
return eval('{' + data);
|
return eval('{' + data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user