Class SingleSampleInstrument
The "drop a sample on the keyboard" instrument: a single audio buffer (a loaded WAV or a recorded snippet) auto-mapped across the keyboard at a chosen root key, with editable start/end and loop points, loop mode, tuning, gain, pan, velocity tracking and an amplitude envelope. It is the simplest producer of the format-neutral region the voice plays; edits are picked up by the next note (see SingleSampleSampler).
Properties are plain mutable settings so a UI can bind to them directly.
public sealed class SingleSampleInstrument
- Inheritance
-
SingleSampleInstrument
- Inherited Members
Constructors
SingleSampleInstrument(float[], int, int, float[])
Creates an instrument from a sample buffer, mapped across the whole keyboard at the given root key.
public SingleSampleInstrument(float[] data, int sampleRate, int rootKey = 60, float[] dataRight = null)
Parameters
datafloat[]The sample, or the left channel of a stereo sample (-1..1).
sampleRateintThe sample's recording rate in Hz.
rootKeyintThe MIDI key that plays it at recorded pitch (default 60).
dataRightfloat[]The right channel of a stereo sample, or null for mono.
Properties
AttackSeconds
Amplitude-envelope attack in seconds (default 0, instant).
public float AttackSeconds { get; set; }
Property Value
DecaySeconds
Amplitude-envelope decay in seconds (default 0).
public float DecaySeconds { get; set; }
Property Value
DelaySeconds
Amplitude-envelope delay in seconds (default 0).
public float DelaySeconds { get; set; }
Property Value
End
Playback end in frames (default the sample length).
public int End { get; set; }
Property Value
HiKey
Highest mapped MIDI key, inclusive (default 127).
public int HiKey { get; set; }
Property Value
HiVelocity
Highest mapped velocity, inclusive (default 127).
public int HiVelocity { get; set; }
Property Value
HoldSeconds
Amplitude-envelope hold in seconds (default 0).
public float HoldSeconds { get; set; }
Property Value
IsStereo
Whether the loaded sample is stereo.
public bool IsStereo { get; }
Property Value
Length
The sample length in frames.
public int Length { get; }
Property Value
LoKey
Lowest mapped MIDI key, inclusive (default 0).
public int LoKey { get; set; }
Property Value
LoVelocity
Lowest mapped velocity, inclusive (default 0).
public int LoVelocity { get; set; }
Property Value
LoopCrossfadeSeconds
Loop-seam crossfade length in seconds (default 0). Smooths the loop wrap when the loop points don't fall on matching samples. Limited by the audio before LoopStart, so set a loop start that has some lead-in.
public float LoopCrossfadeSeconds { get; set; }
Property Value
LoopEnd
Loop end in frames (default the sample length).
public int LoopEnd { get; set; }
Property Value
LoopMode
Loop behaviour (default none).
public LoopMode LoopMode { get; set; }
Property Value
LoopStart
Loop start in frames (default 0).
public int LoopStart { get; set; }
Property Value
Pan
Pan, −1 (left) … +1 (right) (default 0, centre).
public float Pan { get; set; }
Property Value
ReleaseSeconds
Amplitude-envelope release in seconds (default 0.01, an anti-click tail).
public float ReleaseSeconds { get; set; }
Property Value
RootKey
The MIDI key that plays the sample at its recorded pitch (default 60).
public int RootKey { get; set; }
Property Value
SampleRate
The sample's recording rate in Hz.
public int SampleRate { get; }
Property Value
Start
Playback start in frames (default 0).
public int Start { get; set; }
Property Value
SustainLevel
Amplitude-envelope sustain level, 0..1 (default 1).
public float SustainLevel { get; set; }
Property Value
TuneCents
Fixed detune in cents (default 0).
public double TuneCents { get; set; }
Property Value
VelocityTrackingPercent
Velocity-to-amplitude tracking percent (default 100; 0 = velocity ignored).
public float VelocityTrackingPercent { get; set; }
Property Value
VolumeDb
Gain in decibels (default 0).
public float VolumeDb { get; set; }