Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 4f6c4bb

Browse files
authored
Merge pull request #1040 from fnordomat/soundfont-url
WIP: make soundfont base url configurable
2 parents f5bb88a + b233c33 commit 4f6c4bb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/soundfonts/fontloader.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ import {
99
} from '@strudel/webaudio';
1010
import gm from './gm.mjs';
1111

12+
let defaultSoundfontUrl = 'https://felixroos.github.io/webaudiofontdata/sound';
13+
let soundfontUrl = defaultSoundfontUrl;
14+
15+
export function setSoundfontUrl(value) {
16+
soundfontUrl = value;
17+
}
18+
1219
let loadCache = {};
1320
async function loadFont(name) {
1421
if (loadCache[name]) {
1522
return loadCache[name];
1623
}
1724
const load = async () => {
1825
// TODO: make soundfont source configurable
19-
const url = `https://felixroos.github.io/webaudiofontdata/sound/${name}.js`;
26+
const url = `${soundfontUrl}/${name}.js`;
2027
const preset = await fetch(url).then((res) => res.text());
2128
let [_, data] = preset.split('={');
2229
return eval('{' + data);

packages/soundfonts/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { getFontBufferSource, registerSoundfonts } from './fontloader.mjs';
1+
import { getFontBufferSource, registerSoundfonts, setSoundfontUrl } from './fontloader.mjs';
22
import * as soundfontList from './list.mjs';
33
import { startPresetNote } from 'sfumato';
44
import { loadSoundfont } from './sfumato.mjs';
55

6-
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList, registerSoundfonts };
6+
export { loadSoundfont, startPresetNote, getFontBufferSource, soundfontList, registerSoundfonts, setSoundfontUrl };

0 commit comments

Comments
 (0)