Class SampleSource
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
datafloat[]Mono sample data.
sampleRateintNative sample rate in Hz.
loopModeLoopModeLoop behaviour.
startint?First playable sample index, or null for 0.
endint?End playable sample index (exclusive), or null for the full length.
loopStartint?Loop start sample index, or null for
start.loopEndint?Loop end sample index (exclusive), or null for
end.crossfadeSamplesintLoop-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
Data
The mono sample data.
public float[] Data { get; }
Property Value
- float[]
End
End playable sample index (exclusive).
public int End { get; }
Property Value
LoopEnd
Loop end sample index (exclusive) — the sample at this index is not played within the loop.
public int LoopEnd { get; }
Property Value
LoopMode
How the sample loops.
public LoopMode LoopMode { get; }
Property Value
LoopStart
Loop start sample index (inclusive).
public int LoopStart { get; }
Property Value
SampleRate
The native sample rate of Data in Hz.
public int SampleRate { get; }
Property Value
Start
First playable sample index (inclusive).
public int Start { get; }