Reference getAudioContext()

getAudioContext()

Get the window's audio context. For patching p5.sound.js into other JavaScript sound libraries. Returns the AudioContext that p5.sound.js plays through and builds its node graph on directly, so ordinary Web Audio code such as `ctx.createGain().connect(ctx.destination)` works against it. It is the browser's own AudioContext, which is what lets another audio library share it. Hand it to that library's own context setter before creating any of its objects — `Tone.setContext(getAudioContext())` for Tone.js — and nodes from both libraries can then be connected to each other.

Examples

Returns

AudioContext: the audio context

Related References