Skip to main content

AudioSource Binders

Binders for every property of the AudioSource component.


Overview

Every AudioSource property has its own binder, a Switcher variant and MonoBinder wrappers (plain, Enum, EnumGroup).

BinderPropertyData type
AudioSourceVolumeBindervolumefloat
AudioSourcePitchBinderpitchfloat
AudioSourceClipBinderclipAudioClip
AudioSourceLoopBinderloopbool
AudioSourceMuteBindermutebool
AudioSourcePanStereoBinderpanStereofloat
AudioSourceSpatialBlendBinderspatialBlendfloat
AudioSourceSpreadBinderspreadfloat
AudioSourceDopplerLevelBinderdopplerLevelfloat
AudioSourcePriorityBinderpriorityint
AudioSourceTimeBindertimefloat
AudioSourceTimeSamplesBindertimeSamplesint
AudioSourceReverbZoneMixBinderreverbZoneMixfloat
AudioSourceMinMaxDistanceBinderminDistance / maxDistanceVector2
AudioSourceBypassEffectsBinderbypassEffectsbool
AudioSourceBypassListenerEffectsBinderbypassListenerEffectsbool
AudioSourceBypassReverbZonesBinderbypassReverbZonesbool
AudioSourceOutputAudioMixerGroupBinderoutputAudioMixerGroupAudioMixerGroup

All binders: OneWay, OneTime, OneWayToSource (TwoWay is not allowed).


Float binders

The numeric binders (Volume, Pitch, PanStereo and others) implement INumberBinder and accept int, float, long, double.

Ranges the value is clamped to (NaN and infinity are logged and replaced with the lower bound):

BinderRange
Volume, SpatialBlend0..1
PanStereo-1..1
Pitch-3..3
DopplerLevel0..5
ReverbZoneMix0..1.1
Spread0..360
Priority0..256
Time, TimeSamplesinside the current clip; without a clip the write is skipped
MinMaxDistancenegatives are raised to 0, an inverted pair is swapped
[ViewModel]
public partial class AudioViewModel
{
[OneWayBind] private float _volume;
[OneWayBind] private float _pitch;
[OneWayBind] private bool _mute;
}

AudioSourceMinMaxDistanceBinder

Binds AudioSource.minDistance / AudioSource.maxDistance through a Vector2 (like SliderMinMaxBinder).

AudioSourceDistanceMode

ModeBehaviour
MinUpdates minDistance only
MaxUpdates maxDistance only
RangeUpdates both

AudioSourceClipBinder

Binds AudioSource.clip (AudioClip).

[ViewModel]
public partial class MusicPlayerViewModel
{
[OneWayBind] private AudioClip _currentTrack;
}

Switcher variants

Every binder has a Switcher variant (bool → one of two values):

  • AudioSourceVolumeSwitcherBinder: boolfloat
  • AudioSourcePitchSwitcherBinder: boolfloat
  • AudioSourceClipSwitcherBinder: boolAudioClip
  • AudioSourceMinMaxDistanceSwitcherBinder: boolVector2
  • AudioSourceOutputAudioMixerGroupSwitcherBinder: boolAudioMixerGroup
  • and so on

AudioSourceToSourceMonoBinder

A MonoBinder for OneWayToSource binding of the AudioSource as a component. Inherits ComponentToSourceMonoBinder<AudioSource>.


See also