Envelope generator (ADSR)
More...
|
| EnvelopeGenerator () |
| Creates and Initializes an Envelope Generator.
|
|
float | Process () |
| Processes the envelope state and returns the output value.
|
|
void | Gate (bool gate) |
| Sets the envelope state based on the gate condition.
|
|
void | Reset () |
| Resets the state of the envelope and sets the output to 0.0f.
|
|
float | GetOutput () |
| Gets the output value.
|
|
|
float | AttackRate [get, set] |
| Attack Rate (seconds * SamplesPerSecond)
|
|
float | DecayRate [get, set] |
| Decay Rate (seconds * SamplesPerSecond)
|
|
float | ReleaseRate [get, set] |
| Release Rate (seconds * SamplesPerSecond)
|
|
float | SustainLevel [get, set] |
| Sustain Level (1 = 100%)
|
|
EnvelopeState | State [get] |
| Current envelope state.
|
|
|
void | SetTargetRatioAttack (float targetRatio) |
| Sets the target ratio for attack and updates the attack base.
|
|
void | SetTargetRatioDecayRelease (float targetRatio) |
| Sets the target ratio for decay and release and calculates the decay and release bases.
|
|
|
static float | CalcCoef (float rate, float targetRatio) |
| Calculates the coefficient using the given rate and target ratio and returns the result.
|
|
Envelope generator (ADSR)
◆ EnvelopeState
Envelope State.
Enumerator |
---|
Idle | Idle.
|
Attack | Attack.
|
Decay | Decay.
|
Sustain | Sustain.
|
Release | Release.
|
◆ EnvelopeGenerator()
NAudio.Dsp.EnvelopeGenerator.EnvelopeGenerator |
( |
| ) |
|
|
inline |
Creates and Initializes an Envelope Generator.
◆ CalcCoef()
static float NAudio.Dsp.EnvelopeGenerator.CalcCoef |
( |
float | rate, |
|
|
float | targetRatio ) |
|
inlinestaticprivate |
Calculates the coefficient using the given rate and target ratio and returns the result.
- Parameters
-
rate | The rate used in the calculation. |
targetRatio | The target ratio used in the calculation. |
- Returns
- The calculated coefficient based on the provided rate and targetRatio .
This method calculates the coefficient using the formula: coefficient = (float)Math.Exp(-Math.Log((1.0f + targetRatio) / targetRatio) / rate).
◆ Gate()
void NAudio.Dsp.EnvelopeGenerator.Gate |
( |
bool | gate | ) |
|
|
inline |
Sets the envelope state based on the gate condition.
- Parameters
-
gate | The condition to set the envelope state. If true, sets the state to EnvelopeState.Attack; otherwise, sets the state to EnvelopeState.Release if the current state is not EnvelopeState.Idle. |
This method sets the envelope state based on the gate condition. If the gate is true, it sets the state to attack. If the gate is false and the current state is not idle, it sets the state to release.
◆ GetOutput()
float NAudio.Dsp.EnvelopeGenerator.GetOutput |
( |
| ) |
|
|
inline |
Gets the output value.
- Returns
- The output value.
◆ Process()
float NAudio.Dsp.EnvelopeGenerator.Process |
( |
| ) |
|
|
inline |
Processes the envelope state and returns the output value.
- Returns
- The output value after processing the envelope state.
This method processes the envelope state based on the current state and coefficients for attack, decay, sustain, and release. It updates the output value according to the state transitions and coefficient calculations. The method returns the final output value after processing the envelope state.
◆ Reset()
void NAudio.Dsp.EnvelopeGenerator.Reset |
( |
| ) |
|
|
inline |
Resets the state of the envelope and sets the output to 0.0f.
◆ SetTargetRatioAttack()
void NAudio.Dsp.EnvelopeGenerator.SetTargetRatioAttack |
( |
float | targetRatio | ) |
|
|
inlineprivate |
Sets the target ratio for attack and updates the attack base.
- Parameters
-
targetRatio | The target ratio for attack. |
If the targetRatio is less than 0.000000001f, it is set to 0.000000001f (-180 dB). The targetRatio is then assigned to targetRatioAttack and the attackBase is updated using the formula: (1.0f + targetRatioAttack) * (1.0f - attackCoef).
◆ SetTargetRatioDecayRelease()
void NAudio.Dsp.EnvelopeGenerator.SetTargetRatioDecayRelease |
( |
float | targetRatio | ) |
|
|
inlineprivate |
Sets the target ratio for decay and release and calculates the decay and release bases.
- Parameters
-
targetRatio | The target ratio for decay and release. |
If the targetRatio is less than 0.000000001f, it is set to 0.000000001f (-180 dB). The decay base is calculated as (sustainLevel - targetRatioDecayRelease) * (1.0f - decayCoef). The release base is calculated as -targetRatioDecayRelease * (1.0f - releaseCoef).
◆ attackBase
float NAudio.Dsp.EnvelopeGenerator.attackBase |
|
private |
◆ attackCoef
float NAudio.Dsp.EnvelopeGenerator.attackCoef |
|
private |
◆ attackRate
float NAudio.Dsp.EnvelopeGenerator.attackRate |
|
private |
◆ decayBase
float NAudio.Dsp.EnvelopeGenerator.decayBase |
|
private |
◆ decayCoef
float NAudio.Dsp.EnvelopeGenerator.decayCoef |
|
private |
◆ decayRate
float NAudio.Dsp.EnvelopeGenerator.decayRate |
|
private |
◆ output
float NAudio.Dsp.EnvelopeGenerator.output |
|
private |
◆ releaseBase
float NAudio.Dsp.EnvelopeGenerator.releaseBase |
|
private |
◆ releaseCoef
float NAudio.Dsp.EnvelopeGenerator.releaseCoef |
|
private |
◆ releaseRate
float NAudio.Dsp.EnvelopeGenerator.releaseRate |
|
private |
◆ state
◆ sustainLevel
float NAudio.Dsp.EnvelopeGenerator.sustainLevel |
|
private |
◆ targetRatioAttack
float NAudio.Dsp.EnvelopeGenerator.targetRatioAttack |
|
private |
◆ targetRatioDecayRelease
float NAudio.Dsp.EnvelopeGenerator.targetRatioDecayRelease |
|
private |
◆ AttackRate
float NAudio.Dsp.EnvelopeGenerator.AttackRate |
|
getset |
Attack Rate (seconds * SamplesPerSecond)
◆ DecayRate
float NAudio.Dsp.EnvelopeGenerator.DecayRate |
|
getset |
Decay Rate (seconds * SamplesPerSecond)
◆ ReleaseRate
float NAudio.Dsp.EnvelopeGenerator.ReleaseRate |
|
getset |
Release Rate (seconds * SamplesPerSecond)
◆ State
◆ SustainLevel
float NAudio.Dsp.EnvelopeGenerator.SustainLevel |
|
getset |
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Core/Dsp/EnvelopeGenerator.cs