Table of Contents

Class Slot

Namespace
Sigil.Sound
Assembly
Sigil.Sound.dll

A hot-swappable place in a chain. Sigil.Sound.Slot.Sound can go anywhere a sound goes; Sigil.Sound.Slot.Swap(Sigil.Sound.Sound,System.Nullable{System.Double}) replaces what plays there in every running render, with a short equal-power crossfade so the change doesn't click.

public sealed class Slot

Inheritance

Inherited Members

Examples

// A slot is a place in a graph whose sound can be replaced while it plays, without a click.
var slot = new Slot(Sine(220));
var chain = slot.Sound.LowPass(800) * 0.5;
slot.Swap(Saw(220));   // from any thread, at any time: the new sound crossfades in
chain

Remarks

Sigil.Sound.Slot.Swap(Sigil.Sound.Sound,System.Nullable{System.Double}) compiles the new sound on the calling thread, never on the audio thread, and hands it over with an atomic exchange that the audio thread picks up on its next block. Replaced operators that implement System.IDisposable are disposed on a later Sigil.Sound.Slot.Swap(Sigil.Sound.Sound,System.Nullable{System.Double}) call, once the audio thread has let go of them.

Constructors

Slot(Sound, double)

Creates a slot that plays initial until it is swapped.

public Slot(Sound initial, double fadeSeconds = 0.02)

Parameters

initial Sound

The sound to play first.

fadeSeconds double

How long a swap crossfades from the old sound to the new one.

Exceptions

ArgumentOutOfRangeException

fadeSeconds is negative or not a number.

Fields

DefaultFadeSeconds

The default crossfade length: 20 ms.

public const double DefaultFadeSeconds = 0.02

Field Value

double

Properties

Current

What the slot plays now: the initial sound or the last one swapped in.

public Sound Current { get; }

Property Value

Sound

FadeSeconds

The crossfade length Sigil.Sound.Slot.Swap(Sigil.Sound.Sound,System.Nullable{System.Double}) uses when none is given. Zero swaps instantly.

public double FadeSeconds { get; }

Property Value

double

Sound

The sound to place in a chain. Every compile of it follows this slot's swaps.

public Sound Sound { get; }

Property Value

Sound

Methods

Swap(Sound, double?)

Replaces the slot's sound in every running render, crossfading over fadeSeconds (default Sigil.Sound.Slot.FadeSeconds; zero swaps on the next block without a fade). Compiles on the calling thread; safe to call while another thread renders.

public void Swap(Sound next, double? fadeSeconds = null)

Parameters

next Sound
fadeSeconds double?

ToString()

A short description of the slot and the sound it holds now.

public override string ToString()

Returns

string

Operators

implicit operator Sound(Slot)

Uses the slot as a sound, to place it in a graph.

public static implicit operator Sound(Slot slot)

Parameters

slot Slot

Returns

Sound

implicit operator Param(Slot)

Uses the slot as a parameter, so a swappable sound can modulate another.

public static implicit operator Param(Slot slot)

Parameters

slot Slot

Returns

Param