feat(webaudio): enable AudioContext sharing for webaudioRepl
- Add support for optional `existingAudioCtx` parameter in `webaudioRepl()` function - When provided, sets it as the default AudioContext via `setDefaultAudioContext()` - Allows integration with external systems that manage their own Web Audio API context - Maintains backward compatibility with existing usage patterns
This commit is contained in:
parent
2998de8426
commit
4e14718e93
1 changed files with 4 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||
*/
|
||||
|
||||
import * as strudel from '@strudel/core';
|
||||
import { superdough, getAudioContext, setLogger, doughTrigger, registerWorklet } from 'superdough';
|
||||
import { superdough, setDefaultAudioContext, getAudioContext, setLogger, doughTrigger, registerWorklet } from 'superdough';
|
||||
import './supradough.mjs';
|
||||
import { workletUrl } from 'supradough';
|
||||
|
||||
|
|
@ -27,6 +27,9 @@ export const webaudioOutput = (hap, _deadline, hapDuration, cps, t) => {
|
|||
};
|
||||
|
||||
export function webaudioRepl(options = {}) {
|
||||
if (options.existingAudioCtx) {
|
||||
setDefaultAudioContext(options.existingAudioCtx);
|
||||
}
|
||||
options = {
|
||||
getTime: () => getAudioContext().currentTime,
|
||||
defaultOutput: webaudioOutput,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue