Table of Contents

Class FadeInOutSampleProvider

Namespace
NAudio.Wave.SampleProviders
Assembly
NAudio.Core.dll

Sample Provider to allow fading in and out

public class FadeInOutSampleProvider : ISampleProvider
Inheritance
FadeInOutSampleProvider
Implements
Inherited Members
Extension Methods

Constructors

FadeInOutSampleProvider(ISampleProvider, bool)

Creates a new FadeInOutSampleProvider

public FadeInOutSampleProvider(ISampleProvider source, bool initiallySilent = false)

Parameters

source ISampleProvider

The source stream with the audio to be faded in or out

initiallySilent bool

If true, we start faded out

Properties

WaveFormat

WaveFormat of this SampleProvider

public WaveFormat WaveFormat { get; }

Property Value

WaveFormat

Methods

BeginFadeIn(double)

Requests that a fade-in begins (will start on the next call to Read)

public void BeginFadeIn(double fadeDurationInMilliseconds)

Parameters

fadeDurationInMilliseconds double

Duration of fade in milliseconds

BeginFadeOut(double)

Requests that a fade-out begins (will start on the next call to Read)

public void BeginFadeOut(double fadeDurationInMilliseconds)

Parameters

fadeDurationInMilliseconds double

Duration of fade in milliseconds

Read(Span<float>)

Reads samples from this sample provider into a span

public int Read(Span<float> buffer)

Parameters

buffer Span<float>

Returns

int

Events

FadeInComplete

Raised once when a fade-in started via BeginFadeIn(double) reaches full volume. Fires from the Read(Span<float>) call on which the transition happens, after the internal lock has been released, so handlers may safely call back into BeginFadeIn(double) / BeginFadeOut(double) (e.g. to schedule a fade-out).

public event EventHandler FadeInComplete

Event Type

EventHandler

FadeOutComplete

Raised once when a fade-out started via BeginFadeOut(double) reaches silence. Fires from the Read(Span<float>) call on which the transition happens, after the internal lock has been released, so handlers may safely call back into BeginFadeIn(double) / BeginFadeOut(double) (e.g. to signal stop, or start a cross-fade into the next source).

public event EventHandler FadeOutComplete

Event Type

EventHandler