mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 13:48:40 +00:00
Merge pull request #1040 from fnordomat/soundfont-url
WIP: make soundfont base url configurable
This commit is contained in:
commit
4f6c4bb95f
@ -9,6 +9,13 @@ import {
|
|||||||
} from '@strudel/webaudio';
|
} from '@strudel/webaudio';
|
||||||
import gm from './gm.mjs';
|
import gm from './gm.mjs';
|
||||||
|
|
||||||
|
let defaultSoundfontUrl = 'https://felixroos.github.io/webaudiofontdata/sound';
|
||||||
|
let soundfontUrl = defaultSoundfontUrl;
|
||||||
|
|
||||||
|
export function setSoundfontUrl(value) {
|
||||||
|
soundfontUrl = value;
|
||||||
|
}
|
||||||
|
|
||||||
let loadCache = {};
|
let loadCache = {};
|
||||||
async function loadFont(name) {
|
async function loadFont(name) {
|
||||||
if (loadCache[name]) {
|
if (loadCache[name]) {
|
||||||
@ -16,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 = `https://felixroos.github.io/webaudiofontdata/sound/${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);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { getFontBufferSource, registerSoundfonts } from './fontloader.mjs';
|
import { getFontBufferSource, registerSoundfonts, setSoundfontUrl } from './fontloader.mjs';
|
||||||
import * as soundfontList from './list.mjs';
|
import * as soundfontList from './list.mjs';
|
||||||
import { startPresetNote } from 'sfumato';
|
import { startPresetNote } from 'sfumato';
|
||||||
import { loadSoundfont } from './sfumato.mjs';
|
import { loadSoundfont } from './sfumato.mjs';
|
||||||
|
|
||||||
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList, registerSoundfonts };
|
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList, registerSoundfonts, setSoundfontUrl };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user