Struct VolumeEnvelope

Namespace
SpessaSharp.Synthesizer.Engine.Voice
Assembly
SpessaSharp.dll

Applies a volume envelope for a given voice. For performance reasons, cbAttenuationToGain is inlined here.

public struct VolumeEnvelope
Inherited Members

Constructors

VolumeEnvelope(int, int)

public VolumeEnvelope(int sampleRate, int bufferSize)

Parameters

sampleRate int

Hz

bufferSize int

samples

Fields

AttenuationCb

The current attenuation of the envelope in cB.

public float AttenuationCb

Field Value

float

OutputGain

The target gain for the current rendering block.

public float OutputGain

Field Value

float

State

The current stage of the volume envelope.

public VolumeEnvelope.VEState State

Field Value

VolumeEnvelope.VEState

Methods

Init(Voice)

Initialize the volume envelope

public void Init(Voice voice)

Parameters

voice Voice

The voice this envelope belongs to

Process(int, float)

Calculates the gain value for the last sample in the block and writes it to outputGain. Essentially we use approach of 100dB is silence, 0dB is peak.

public bool Process(int sampleCount, float gainTarget)

Parameters

sampleCount int

The amount of samples to write

gainTarget float

The gain to apply.

Returns

bool

If the voice has finished.

Exceptions

ArgumentOutOfRangeException

StartRelease(Voice)

Starts the release phase in the envelope.

public bool StartRelease(Voice voice)

Parameters

voice Voice

The voice this envelope belongs to.

Returns

bool

If the voice is off.

Exceptions

ArgumentOutOfRangeException