A root output lets you implement custom audio systems or sound generators, and integrate third party middleware (FMOD, Wise) that write directly to the main output, bypassing the Unity’s built-in mixer entirely.
You can set up root outputs from code using the following steps:
RootOutputInstance.IRealtime
and RootOutputInstance.IControl
.ControlContext.AllocateRootOutput
, passing your real-time and control implementations.ControlContext.Destroy
to release it.When you use ControlContext.AllocateRootOutput
with the built-in control context, it connects the new root output to Unity’s main audio output and uses the real-time part of your instance to generate audio.
Implementations of RootOutputInstance.IRealtime
processes audio in three stages:
At the end of early processing, each root output might return an optional JobHandle
. Before the processing stage starts, Unity combines all returned handles into a single dependency and passes this dependency to every root output during processing. If you schedule jobs in the processing stage, use this dependency to make sure any work started in early processing completes first.
For each invocation of a root output, the early processing, processing, and end processing stages all execute sequentially on the same thread. Depending on the control context, this thread might be the audio thread (for the built-in context) or a job worker thread (for manual contexts).
The following real-time constraints apply to all three stages:
UnityEngine
APIs from within Process
. Use thread-safe and lock-free patterns for synchronizing shared state.Unity.Mathematics
and lay out data for Burst auto-vectorization.JobHandle
from the early stage if you schedule work there.