Class SampleProviderMulti
Namespace: ValveResourceFormat.Renderer.Audio.SampleProviders
Assembly: Renderer.dll
Sums multiple sample providers into one stream. Providers that run out of samples are removed automatically. Thread safe: providers can be added and removed while the mixing thread is reading.
public class SampleProviderMulti : AudioSampleProvider, IAudioSampleProviderInheritance
object ← AudioSampleProvider ← SampleProviderMulti
Derived
Implements
Inherited Members
AudioSampleProvider.OnOver, AudioSampleProvider.Volume, AudioSampleProvider.VolumeMultiplier, AudioSampleProvider.Read(float[], int, int), AudioSampleProvider.Over()
Constructors
SampleProviderMulti()
Creates an empty mixer.
public SampleProviderMulti()Methods
AddProvider(IAudioSampleProvider)
Adds a provider to the mix. Idempotent: providers get auto-removed when they run dry and re-added when they resume (e.g. retriggered child events), which must not create duplicates.
public void AddProvider(IAudioSampleProvider provider)Parameters
provider IAudioSampleProvider
BeginFadeIn(float, int)
Starts fading the mix in from silence over seconds, eased rather than linear so a freshly started event (e.g. entering a soundscape with none previously active) doesn't jump straight to full volume. Harmless to call more than once; only the first call takes effect.
public void BeginFadeIn(float seconds, int sampleRate)Parameters
seconds float
sampleRate int
BeginFadeOut(SoundEventCurve?, float, int)
Starts fading the mix out: subsequent reads ramp the volume down along curve (or linearly over fallbackSeconds when null) and the mix ends when the fade completes.
public void BeginFadeOut(SoundEventCurve? curve, float fallbackSeconds, int sampleRate)Parameters
curve SoundEventCurve?
fallbackSeconds float
sampleRate int
ClearProviders()
Removes all providers from the mix.
public void ClearProviders()Read(float[], int, int)
Fills buffer with up to count samples starting at offset. Returns the number of samples written. A return value smaller than count signals the end of the sound.
public override int Read(float[] buffer, int offset, int count)Parameters
buffer float[]
offset int
count int
Returns
RemoveProvider(IAudioSampleProvider)
Removes a provider from the mix.
public void RemoveProvider(IAudioSampleProvider provider)Parameters
provider IAudioSampleProvider
ResetFades()
Clears any fade-out/fade-in in progress, so a pooled sound event reused for a new play does not start silent (or mid-fade) because its previous play ended in a fade.
public void ResetFades()
