Class SampleLibrary
- Namespace
- Sigil.Sound
- Assembly
- Sigil.Sound.dll
The samples available to a script, by name. In a script it is the Samples object: Samples.Load("kick.wav")
gives an Sigil.Sound.AudioBuffer to play with Sigil.Sound.Sounds.Sample(Sigil.Sound.AudioBuffer,System.Nullable{Sigil.Sound.Param},Sigil.Sound.PlaybackMode,System.Double,System.Nullable{System.Double}).
The browser REPL fills it with the WAV files you drop onto the page, and Audio Workbench's Sound Script with the
Asset Manager's sample library, so a script reads the same in both.
public sealed class SampleLibraryInheritance
Inherited Members
Remarks
A script names a sample; it never gives a file path. Only names the host lists can be loaded, so a script cannot reach any other file on the machine.
Constructors
SampleLibrary(ISampleSource)
Creates a library that reads from source.
public SampleLibrary(ISampleSource source)Parameters
sourceISampleSource-
The host's sample store.
Properties
Names
The names of the samples that can be loaded right now, for example kick.wav or drums/snare.wav.
public IReadOnlyList<string> Names { get; }Property Value
Methods
Contains(string)
Whether a sample with this name exists. Case is ignored if no name matches exactly.
public bool Contains(string name)Parameters
namestring-
The sample's name as listed in Sigil.Sound.SampleLibrary.Names.
Returns
Load(string)
Loads a sample from the library, ready to play with Sample(...). While typing the name, the editor lists the samples
that are available. Loading happens when the script is compiled, not while it plays, and the same sample can be loaded
any number of times.
public AudioBuffer Load(string name)Parameters
namestring-
The sample's name, such as
"kick.wav"or"drums/snare.wav". Matching ignores case when there is no exact match.
Returns
- AudioBuffer
-
The decoded audio at the file's own sample rate; playback converts it to the output rate.
Examples
// The REPL ships with pluck.wav; drop your own .wav files on the page to add more.
var pluck = Samples.Load("pluck.wav");
Sample(pluck, speed: 1)
Exceptions
- KeyNotFoundException
-
There is no sample with that name. The message lists names that are available.