I'm working with the Web Audio API, and one of the main components is an AudioContext. This object is passed around everywhere, but there's really only one so I'm thinking I should just make it a global and be done with it.
Before I do that -- though -- I'd like to know: what's the use case for having multiple? Is it just so if two separate codebases are using an audio context and one breaks, the other is left intact? Would it be fair to say that within a single project, there should almost ever be one?
"It's recommended to create one AudioContext and reuse it instead of initializing a new one each time, and it's OK to use a single AudioContext for several different audio source and pipeline concurrently."
https://developer.mozilla.org/en-US/docs/Web/API/AudioContext
Here are some use-cases for multiple AudioContexts:
The latter two of these are the most interesting (sandboxing, no argument drilling). If you have a project where outputs don't need to be mixed in any special way, these two could be beneficial.