SoundEffectSourceComponent Class
Definition¶
Namespace: Brine2D.Systems.Audio
Audio source for one-shot or looping sound effects. Supports spatial audio when EnableSpatialAudio is set and a TransformComponent is present on the same entity.
public class SoundEffectSourceComponent : Brine2D.Systems.Audio.AudioSourceComponent
Inheritance System.Object → Component → AudioSourceComponent → SoundEffectSourceComponent
Remarks¶
Multiple tracks can play concurrently on the same entity. Triggering play while sounds are already playing adds a new overlapping track. Use TriggerStop to stop all active tracks, or MaxConcurrentInstances to limit how many instances of the same sound can overlap globally.
| Properties | |
|---|---|
| DopplerFactor | Doppler effect intensity multiplier. 0 = disabled, 1 = realistic. Higher values exaggerate the pitch shift. Clamped to [0, 5]. Default 0 (disabled). Requires EnableSpatialAudio to be set. |
| EnableSpatialAudio | Enable 2D spatial audio (distance-based volume + stereo panning). Requires a TransformComponent on the same entity. |
| FadeInDuration | Duration in seconds for fading in when the sound starts playing. Zero means instant full volume. Clamped to [0, ∞). Default 0. |
| FadeOutDuration | Duration in seconds for fading out when TriggerStop is consumed. Zero means immediate stop. Clamped to [0, ∞). Default 0. Setting TriggerStop a second time during an active fade-out forces an immediate stop. |
| MaxConcurrentInstances | Maximum number of concurrent tracks across all entities playing the same SoundEffect. Zero means unlimited. Default 0. |
| MaxDistance | Maximum distance where sound becomes inaudible (volume = 0). Clamped to [0, ∞). Setting a value below MinDistance lowers MinDistance to match. |
| MinDistance | Minimum distance where sound is at full volume (no attenuation). Clamped to [0, MaxDistance]. Setting a value above MaxDistance raises MaxDistance to match. |
| PitchVariation | Maximum random pitch offset applied each time the sound plays. The actual pitch is jittered by ±PitchVariation around Pitch. Clamped to [0, 1]. Default 0. |
| RolloffFactor | Rolloff factor controls how quickly volume decreases with distance. 0 = no rolloff, 1 = linear, 2 = quadratic (more realistic). Negative values are clamped to zero. |
| SoundEffect | Sound effect to play. |
| SpatialBlend | Stereo panning strength (0.0 = center only, 1.0 = full stereo). Values outside the range are clamped. |
| SpatialPan | Calculated stereo pan after spatial processing (managed by AudioSystem). |
| SpatialPitch | Calculated pitch multiplier from Doppler processing (managed by AudioSystem). Combined with Pitch when applying to the track. |
| SpatialVolume | Calculated volume after spatial processing (managed by AudioSystem). |
| TriggerStopOldest | Set to true to stop the oldest overlapping track on the next frame. Consumed and reset to false by AudioSystem each update. Does nothing if no tracks are active on this entity. |
| VolumeVariation | Maximum random volume reduction applied each time the sound plays. The actual volume is reduced by up to this fraction of the computed spatial volume. Clamped to [0, 1]. Default 0. |