mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 12:08:28 +00:00
add disableWorklets option to initAudio
This commit is contained in:
parent
7d0fb0de83
commit
c6095fd92a
@ -62,21 +62,24 @@ function getWorklet(ac, processor, params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this function should be called on first user interaction (to avoid console warning)
|
// this function should be called on first user interaction (to avoid console warning)
|
||||||
export async function initAudio() {
|
export async function initAudio(options = {}) {
|
||||||
|
const { disableWorklets = false } = options;
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
try {
|
await getAudioContext().resume();
|
||||||
await getAudioContext().resume();
|
if (!disableWorklets) {
|
||||||
await loadWorklets();
|
await loadWorklets().catch((err) => {
|
||||||
} catch (err) {
|
console.warn('could not load AudioWorklet effects coarse, crush and shape', err);
|
||||||
console.warn('could not load AudioWorklet effects coarse, crush and shape', err);
|
});
|
||||||
|
} else {
|
||||||
|
console.log('disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initAudioOnFirstClick() {
|
export async function initAudioOnFirstClick(options) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
document.addEventListener('click', async function listener() {
|
document.addEventListener('click', async function listener() {
|
||||||
await initAudio();
|
await initAudio(options);
|
||||||
resolve();
|
resolve();
|
||||||
document.removeEventListener('click', listener);
|
document.removeEventListener('click', listener);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user