Skip to content

Tone context migration - #111

Merged
ogbabydiesal merged 3 commits into
mainfrom
tone-context-migration
Aug 10, 2026
Merged

ogbabydiesal merged 3 commits into
mainfrom
tone-context-migration

Conversation

@ogbabydiesal

Copy link
Copy Markdown
Member

No description provided.

ogbabydiesal and others added 3 commits July 27, 2026 07:54
p5soundNode built its input/output from a raw AudioContext, which left
Firefox missing AudioParam.cancelAndHoldAtTime() and the AudioParam-based
AudioListener properties. Both were patched locally.

Build the graph on the Tone.js Context instead: input/output are now Tone
Gain nodes and connections go through Tone's own connect(), so the fixes
come from the standardized-audio-context layer Tone already bundles and
the two polyfills are deleted.

Keep getAudioContext() returning the plain AudioContext it always did.
Returning the Tone Context breaks ordinary Web Audio code, because
createGain() yields a bare node while destination is a Tone wrapper; the
private getToneContext() serves the graph.

Expose the bundled Tone.js as p5.Tone. Two copies of Tone.js cannot share
an audio graph whichever context they are handed, since each bundles its
own standardized-audio-context whose type checks reject the other's nodes,
so example 020 now uses the bundled copy rather than a CDN script.

Also fixes, all surfaced by the migration:
- Delay.process() threw on setValueAtTime when its optional delayTime and
  feedback arguments were omitted, and now applies both immediately rather
  than through a ramp that cannot advance while the context is suspended.
- Amplitude.setInput(), Delay.process() and Panner3D.process() connected a
  source's input gain instead of its output.
- Three example sketches touched a sound file before loadSound() resolved.

Example suite (Playwright, chromium + firefox): 59 passing before, 66 now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ogbabydiesal
ogbabydiesal merged commit c01819d into main Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant