Table of Contents

Class MixingSampleProvider

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

A sample source mixer, allowing inputs to be added and removed

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

Constructors

MixingSampleProvider(WaveFormat)

Creates a new MixingSampleProvider, with no inputs, but a specified WaveFormat

public MixingSampleProvider(WaveFormat waveFormat)

Parameters

waveFormat WaveFormat

The WaveFormat of this mixer. All inputs must be in this format

MixingSampleProvider(IEnumerable<ISampleProvider>)

Creates a new MixingSampleProvider, based on the given inputs

public MixingSampleProvider(IEnumerable<ISampleProvider> sources)

Parameters

sources IEnumerable<ISampleProvider>

Mixer inputs - must all have the same waveformat, and must all be of the same WaveFormat. There must be at least one input

Properties

MixerInputs

Returns the mixer inputs (read-only - use AddMixerInput to add an input

public IEnumerable<ISampleProvider> MixerInputs { get; }

Property Value

IEnumerable<ISampleProvider>

ReadFully

When set to true, the Read method always returns the number of samples requested, even if there are no inputs, or if the current inputs reach their end. Setting this to true effectively makes this a never-ending sample provider, so take care if you plan to write it out to a file.

public bool ReadFully { get; set; }

Property Value

bool

WaveFormat

The output WaveFormat of this sample provider

public WaveFormat WaveFormat { get; }

Property Value

WaveFormat

Methods

AddMixerInput(ISampleProvider)

Adds a new mixer input

public void AddMixerInput(ISampleProvider mixerInput)

Parameters

mixerInput ISampleProvider

Mixer input

Read(Span<float>)

Reads samples from this sample provider into a span

public int Read(Span<float> buffer)

Parameters

buffer Span<float>

Returns

int

RemoveAllMixerInputs()

Removes all mixer inputs

public void RemoveAllMixerInputs()

RemoveMixerInput(ISampleProvider)

Removes a mixer input

public void RemoveMixerInput(ISampleProvider mixerInput)

Parameters

mixerInput ISampleProvider

Mixer input to remove

Events

MixerInputEnded

Raised when a mixer input has been removed because it has ended

public event EventHandler<SampleProviderEventArgs> MixerInputEnded

Event Type

EventHandler<SampleProviderEventArgs>