Revert "Revert "Merge pull request 'supradough poc' (#1362) from supradough into main""

This reverts commit c0bf86d11e.
This commit is contained in:
Felix Roos 2025-09-12 10:08:55 +02:00
parent c0bf86d11e
commit d164b5e7f5
No known key found for this signature in database
17 changed files with 1493 additions and 63 deletions

View file

@ -196,7 +196,7 @@ export const resetLoadedSounds = () => soundMap.set({});
let audioContext;
export const setDefaultAudioContext = () => {
audioContext = new AudioContext();
audioContext = new AudioContext({ latencyHint: 'playback' });
return audioContext;
};
@ -212,11 +212,17 @@ export function getAudioContextCurrentTime() {
return getAudioContext().currentTime;
}
let externalWorklets = [];
export function registerWorklet(url) {
externalWorklets.push(url);
}
let workletsLoading;
function loadWorklets() {
if (!workletsLoading) {
const audioCtx = getAudioContext();
workletsLoading = audioCtx.audioWorklet.addModule(workletsUrl);
const allWorkletURLs = externalWorklets.concat([workletsUrl]);
workletsLoading = Promise.all(allWorkletURLs.map((workletURL) => audioCtx.audioWorklet.addModule(workletURL)));
}
return workletsLoading;