A voice is one playing sound: mixer.Play returns a handle to it. Set its Bus to group it with other sounds you want to turn up or down together.
dotnet add package RecursiveAI.OneAudioRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneAudio; var mixer = new AudioMixer(new MixerOptions { Channels = 1, MaxBuses = 2 }); var format = new AudioFormat(48000, 1); var clip = new AudioClip(format, [0.5f]); if (!mixer.SetBusGain(1, 0.5f, 0)) throw new InvalidOperationException(); var dry = mixer.Play( new PlayParams(clip) { Bus = 0 }); var group = mixer.Play( new PlayParams(clip) { Bus = 1 }); if (!dry.IsValid || !group.IsValid) throw new InvalidOperationException(); var pcm = new float[1]; mixer.Render(pcm); Console.WriteLine(FormattableString .Invariant($"Master sample: {pcm[0]}"));
The example renders one sample into an array and plays nothing through speakers, so it needs no audio device.
Two voices send 0.5 each to different buses. Bus 0 sends 0.5 to the master; bus 1 halves its contribution to 0.25.
Master sample: 0.75Check for an invalid Play handle or a false bus command result: the command queue may be full.
Unzip the example, then dotnet run.
Variations
To put bus 0 under the same gain as bus 1, insert this before var dry = mixer.Play(...):
if (!mixer.SetBusOutput(0, 1)) throw new InvalidOperationException();
Master sample: 0.5Related recipes
The short answer
Set PlayParams.Bus to the bus number when you start a voice. Reserve the number of buses you need with MixerOptions.MaxBuses; with two buses, the indexes are 0 and 1. Both feed the master output by default. SetBusGain(1, 0.5f, 0) immediately halves bus 1’s contribution at the next render pass, without changing bus 0.
What is a bus on a sound mixer?
It’s a shared path for several signals. A game could route its character voices and sound effects through separate buses and let the player turn the effects down without touching dialogue. Assign voices to groups as you start them; bus 0 is the default for voices with no explicit Bus. Each voice goes to one bus, not to both its bus and the master. SetMasterGain changes the final level rather than one group’s contribution.
Bus gain is linear: 1f leaves the level unchanged, 0.5f halves the sample amplitudes, and 0f makes the bus silent. The example uses zero ramp frames so the change is visible in a single sample. In a live mix, omit the explicit ramp to use MixerOptions.SmoothingMilliseconds rather than stepping the gain abruptly. The mixer reference notes that render sums the streams without clipping them, so leave headroom when you combine louder signals.
What does submix mean?
A submix combines some of the channels before they reach the final mix. The variation routes bus 0 into bus 1, so the two 0.5 signals sum before bus 1 halves the result to 0.5. That is different from changing bus 1’s gain with both buses independently feeding the master, where the result was 0.75.
Choose a parent bus when you want several groups to share one control, but keep their own group controls. SetBusOutput replaces the child’s destination rather than adding a second route. To send it directly to the output again, use AudioMixer.MasterBus as the destination. A route that makes a bus feed itself, even through other buses, throws ArgumentException.