Table of Contents

Class SampleSource

Namespace
NAudio.Dsp
Assembly
NAudio.Core.dll

An immutable block of mono sample data plus the playback metadata a sampler voice needs: the playable extent, the loop points and the loop mode. The data is interpreted by an InterpolatingSampleReader. Pitch/root-key handling lives in the voice, not here — this type only describes the raw sample and how it loops.

public sealed class SampleSource
Inheritance
SampleSource
Inherited Members

Constructors

SampleSource(float[], int, LoopMode, int?, int?, int?, int?, int)

Creates a sample source.

public SampleSource(float[] data, int sampleRate, LoopMode loopMode = LoopMode.None, int? start = null, int? end = null, int? loopStart = null, int? loopEnd = null, int crossfadeSamples = 0)

Parameters

data float[]

Mono sample data.

sampleRate int

Native sample rate in Hz.

loopMode LoopMode

Loop behaviour.

start int?

First playable sample index, or null for 0.

end int?

End playable sample index (exclusive), or null for the full length.

loopStart int?

Loop start sample index, or null for start.

loopEnd int?

Loop end sample index (exclusive), or null for end.

crossfadeSamples int

Loop-seam crossfade length in samples (0 = none).

Properties

CrossfadeSamples

Length, in samples, of the crossfade applied at the loop seam (0 = none). As the read position approaches LoopEnd the outgoing audio is blended into the lead-in before LoopStart, so the loop wraps without the click an abrupt jump between mismatched samples causes. Clamped to the data available before the loop and to the loop length.

public int CrossfadeSamples { get; }

Property Value

int

Data

The mono sample data.

public float[] Data { get; }

Property Value

float[]

End

End playable sample index (exclusive).

public int End { get; }

Property Value

int

LoopEnd

Loop end sample index (exclusive) — the sample at this index is not played within the loop.

public int LoopEnd { get; }

Property Value

int

LoopMode

How the sample loops.

public LoopMode LoopMode { get; }

Property Value

LoopMode

LoopStart

Loop start sample index (inclusive).

public int LoopStart { get; }

Property Value

int

SampleRate

The native sample rate of Data in Hz.

public int SampleRate { get; }

Property Value

int

Start

First playable sample index (inclusive).

public int Start { get; }

Property Value

int