Pepper.SFX
All Guidance pages

Guidance / API reference

AudioBus

Namespace: AudioSystem Inheritance: ScriptableObject

Properties

public string BusName { get; }
public AudioBus ParentBus { get; }
public AudioMixerGroup MixerGroup { get; }
public float VolumeDb { get; }                        // the asset's Volume (SetVolume)
public float VolumeMultiplier { get; }
public float StateOffsetDb { get; }                   // what Offset states add now (runtime only)
public float PlayerVolumeDb { get; set; }             // the player's volume, -80…+24 dB (runtime only)
public bool Mute { get; }
public bool IsMuted { get; }                          // this bus or a parent is muted
public bool Solo { get; }
public IReadOnlyList<EffectSend> Sends { get; }
public bool EnableDucking { get; }
public IReadOnlyList<DuckingTarget> DuckingTargets { get; }
public float DuckingAttack { get; }
public float DuckingRelease { get; }
public AudioTimeMode DuckingTimeMode { get; set; }    // the clock a duck on this bus runs on: Scaled (default) or Unscaled
public BusPauseBehaviour WhilePaused { get; set; }    // a sound posted while paused: DropOneShots (default) or Hold
public bool IsPaused { get; }                         // this bus or a parent is paused
public List<ParameterCurve> ParameterCurves { get; }   // Volume (dB), Low Pass and High Pass (Hz); global scope
public string LowPassParameter { get; }               // the exposed mixer cutoff Low Pass curves write
public string HighPassParameter { get; }              // the exposed mixer cutoff High Pass curves write
public float CurveVolumeGain { get; }                 // the curves' level now, linear (part of GetFinalVolume)
public float LowPassHz { get; }                       // the low-pass cutoff Pepper sets now (22000 = open)
public float HighPassHz { get; }                      // the high-pass cutoff Pepper sets now (10 = open)
public int MaxRealVoices { get; set; }                // its real-voice cap, 0 = none (3.1.0-dev.8)
public int RealVoiceCount { get; }                    // real voices of its sounds and its child buses' now

Max Real Voices (3.1.0-dev.8, USER_GUIDE §6.9; inspector: Voices > Max Real Voices): the most real voices the sounds whose Target Bus is this bus or one of its children may use at once; 0 (the default) = no cap. Over it, the least important of them go virtual, a whole sound at a time, at a sound’s start and in the voice pass, like the Audio Manager’s Max Real Voices, which still applies; a single sound bigger than the cap keeps its most important voices. It never ends a sound.

Parameter Curves (USER_GUIDE §6.6) are evaluated in Pepper’s per-frame step from each parameter’s global value, after smoothing. Volume multiplies into GetFinalVolume (child buses and every assigned voice’s BusGain follow; the serialized VolumeDb is untouched). Low Pass and High Pass ease in octaves over about 20 ms and are written with AudioMixer.SetFloat to the bus’s Mixer Group under LowPassParameter / HighPassParameter when they move; with no Mixer Group or no such exposed parameter the bus logs one warning and stops trying. Pitch curves are ignored. The bus inspector’s Add Low Pass / High Pass to Mixer Group buttons add a Lowpass Simple / Highpass Simple effect and expose its Cutoff freq.


Methods

Volume & Mute

public void SetVolume(float newVolumeDb)
public float GetFinalVolume()
public void SetMute(bool newMute)
public void SetSolo(bool newSolo)

Description: GetFinalVolume() returns the final linear volume including the entire parent bus hierarchy: VolumeDb + StateOffsetDb + PlayerVolumeDb as a gain, times VolumeMultiplier, the ducking and the curves, times the parent’s. It is 0 when this bus or a parent is muted, and while another bus is soloed unless this bus or one of its parents is soloed too. That includes a parent of a soloed bus: it passes the soloed bus through, but its own GetFinalVolume() is 0, so the sounds posted straight to it are silent. SetVolume writes the asset’s Volume (in the editor a Play-mode change stays in the asset).

SetSolo works as on a mixing desk: while any bus is soloed, the soloed buses and their child buses are heard, through their parents (whose volume, mute and ducking still apply), and every other bus is silenced. Sounds posted straight to a parent of a soloed bus are silenced too; solo the parent to hear them. Mute still wins. A solo change reaches every bus’s voices, paused and virtual ones too. Before 3.1.0 (after 3.1.0-dev.12) a bus was heard only if it was soloed itself, so soloing a child bus silenced it too and soloing a parent silenced its children.

Three levels (3.1.0-dev.7, USER_GUIDE §6.8 and §7): Volume is the asset’s (the mix); StateOffsetDb is what the active Offset states give the bus, moved by AudioManager.SetState / ClearState; PlayerVolumeDb is a Settings page’s, set by the game. The last two are runtime only: never written to the asset, 0 at the start of each play session. A state never undoes the player’s volume, nor the player a state.

Voice Management

public void AssignToVoice(AudioVoice voice)
public void RemoveVoice(AudioVoice voice)
public AudioSource GetFirstActiveSource()
public void GetActiveSources(List<AudioSource> outList)

Ducking

public void TriggerDucking(float holdDuration = 0f)
public void ApplyDucking(float amountDb, float attack, float hold, float release)

Description: TriggerDucking() uses the bus’s configured ducking settings. ApplyDucking() applies custom ducking parameters (amountDb is negative dB; times in seconds). Ducking is triggered, not driven by the bus’s output. The deepest duck wins (since 3.1.0-dev.7): each trigger is a duck of its own, and while several run on a bus it follows the deepest at each moment, so none cuts another short (it used to be one envelope per bus, replaced by each trigger). A new duck starts from the level the bus is at, so re-triggering one duck sounds as it always did. Each duck runs on the ducked bus’s DuckingTimeMode as it was when triggered: Scaled (the default) freezes at time scale 0; Unscaled completes during a pause. At most 16 run at once on a bus (the one ending first gives way).

Pause / Resume / IsPaused

public void Pause()
public void Resume()
public bool IsPaused { get; }
public BusPauseBehaviour WhilePaused { get; set; }

public enum BusPauseBehaviour { DropOneShots, Hold }

Description: For a game’s pause: pause the world’s buses and the pause menu’s buses play on. Pause() holds every sound on this bus and its child buses: each fades out over about 25 ms and keeps its place, holding no real voice. Resume() brings them back from there, fading in, every layer of a sound in the same frame so they stay in phase. A child bus is paused while it or a parent is (IsPaused), and Resume() on a child doesn’t override its parent. A sound posted to a paused bus starts held; with DropOneShots (the default) one whose voices don’t loop is dropped before its first sample and its handle finishes at once, with Hold it plays on resume. Separate from AudioHandle.Pause and AudioManager.PauseAll (which still pause at once): a sound plays only when none of them pauses it. Pausing a paused bus, or resuming one that isn’t, does nothing. Not paused at the start of each play session.

Factory Methods (Editor Only)

public static AudioBus CreateNew(string name, AudioBus parent = null, AudioMixerGroup mixer = null)
public void EditorSetConfiguration(string name, AudioBus parent = null, AudioMixerGroup mixer = null)

EffectSend (Nested Class)

[Serializable]
public class EffectSend
{
    public string sendName;
    public float sendLevel;
    public bool prePost;
}

DuckingTarget (Nested Class)

[Serializable]
public class DuckingTarget
{
    public AudioBus targetBus;
    public float duckAmount = -6f;   // attenuation in dB, -80..0
}

From the Pepper.SFX 3.1 guides (API_REFERENCE.md). Something wrong or unclear? Tell me.