Table of Contents

Class SampleChannel

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

Utility class that takes an IWaveProvider input at any bit depth and exposes it as an ISampleProvider. Can turn mono inputs into stereo, and allows adjusting of volume. (The eventual successor to WaveChannel32) This class also serves as an example of how you can link together several simple sample sources to form a more useful class.

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

Constructors

SampleChannel(IWaveProvider)

Initialises a new instance of SampleChannel

public SampleChannel(IWaveProvider waveProvider)

Parameters

waveProvider IWaveProvider

Source audio, must be PCM or IEEE

SampleChannel(IWaveProvider, bool)

Initialises a new instance of SampleChannel

public SampleChannel(IWaveProvider waveProvider, bool forceStereo)

Parameters

waveProvider IWaveProvider

Source audio, must be PCM or IEEE

forceStereo bool

force mono inputs to become stereo

Properties

Volume

Allows adjusting the volume, 1.0f = full volume

public float Volume { get; set; }

Property Value

float

WaveFormat

The WaveFormat of this Sample Source

public WaveFormat WaveFormat { get; }

Property Value

WaveFormat

Methods

Read(Span<float>)

Reads samples from this sample source

public int Read(Span<float> buffer)

Parameters

buffer Span<float>

Returns

int

Events

PreVolumeMeter

Raised periodically to inform the user of the max volume (before the volume meter)

public event EventHandler<StreamVolumeEventArgs> PreVolumeMeter

Event Type

EventHandler<StreamVolumeEventArgs>