Generates an ADSR envelope with the specified time coefficients.
More...
#include <EnvelopeGenerator.hpp>
|
| EnvelopeGenerator (float attackSeconds=ATTACK_SECONDS, float decaySeconds=DECAY_SECONDS, float releaseSeconds=RELEASE_SECONDS, float peakLevel=PEAK_LEVEL, float sustainLevel=SUSTAIN_LEVEL) |
| EnvelopeGenerator constructor.
|
|
void | setAttackSeconds (float attackSeconds) |
| Sets the attack time of the generated envelope.
|
|
float | getAttackSeconds () const |
| Gets the current attack time of the generated envelope.
|
|
void | setDecaySeconds (float decaySeconds) |
| Sets the decay time of the generated envelope.
|
|
float | getDecaySeconds () const |
| Gets the current decay time of the generated envelope.
|
|
void | setReleaseSeconds (float releaseSeconds) |
| Sets the release time of the generated envelope.
|
|
float | getReleaseSeconds () const |
| Gets the current release time of the generated envelope.
|
|
void | setPeakLevel (float peakLevel) |
| Sets the peak level of the generated envelope (the level reached by attack).
|
|
float | getPeakLevel () const |
| Gets the current peak level of the generated envelope (the level reached by attack).
|
|
void | setSustainLevel (float sustainLevel) |
| Sets the sustain level of the generated envelope.
|
|
float | getSustainLevel () const |
| Gets the current sustain level of the generated envelope.
|
|
template<typename T > |
void | generate (T *buffer, const uint numberOfSamples, const uint sampleRate) |
| Generates ADSR envelope data into a data buffer.
|
|
void | trigger () |
| Trigger the envelope generator.
|
|
void | release () |
| Release the envelope generator.
|
|
Generates an ADSR envelope with the specified time coefficients.
ADSR envelope generator.
◆ EnvelopeGenerator()
switchboard::EnvelopeGenerator::EnvelopeGenerator |
( |
float | attackSeconds = ATTACK_SECONDS, |
|
|
float | decaySeconds = DECAY_SECONDS, |
|
|
float | releaseSeconds = RELEASE_SECONDS, |
|
|
float | peakLevel = PEAK_LEVEL, |
|
|
float | sustainLevel = SUSTAIN_LEVEL ) |
EnvelopeGenerator constructor.
- Parameters
-
attackSeconds | The time to reach the peak level from zero. Default is 0.0 seconds. |
decaySeconds | The time to reach the sustain level from peak. Default is 0.0 seconds. |
releaseSeconds | The time to reach zero from sustain level. Default is 0.0 seconds. |
peakLevel | The peak level in the range of 0.0..1.0. Default is 1.0. |
sustainLevel | The sustain level in the range of 0.0..1.0. Default is 1.0. |
◆ generate()
template<typename T >
template void switchboard::EnvelopeGenerator::generate< int16 > |
( |
T * | buffer, |
|
|
const uint | numberOfSamples, |
|
|
const uint | sampleRate ) |
Generates ADSR envelope data into a data buffer.
- Parameters
-
buffer | The data buffer. |
numberOfSamples | The number of samples to generate. |
sampleRate | The sample rate. |
◆ getAttackSeconds()
float switchboard::EnvelopeGenerator::getAttackSeconds |
( |
| ) |
const |
Gets the current attack time of the generated envelope.
- Returns
- The attack time in seconds.
◆ getDecaySeconds()
float switchboard::EnvelopeGenerator::getDecaySeconds |
( |
| ) |
const |
Gets the current decay time of the generated envelope.
- Returns
- The decay time in seconds.
◆ getPeakLevel()
float switchboard::EnvelopeGenerator::getPeakLevel |
( |
| ) |
const |
Gets the current peak level of the generated envelope (the level reached by attack).
- Returns
- The peak level in the range of 0.0..1.0.
◆ getReleaseSeconds()
float switchboard::EnvelopeGenerator::getReleaseSeconds |
( |
| ) |
const |
Gets the current release time of the generated envelope.
- Returns
- The release time in seconds.
◆ getSustainLevel()
float switchboard::EnvelopeGenerator::getSustainLevel |
( |
| ) |
const |
Gets the current sustain level of the generated envelope.
- Returns
- The sustain level in the range of 0.0..1.0.
◆ release()
void switchboard::EnvelopeGenerator::release |
( |
| ) |
|
Release the envelope generator.
The generator will release the sustain level in releaseSeconds time.
◆ setAttackSeconds()
void switchboard::EnvelopeGenerator::setAttackSeconds |
( |
float | attackSeconds | ) |
|
Sets the attack time of the generated envelope.
- Parameters
-
attackSeconds | The new attack time value in seconds. |
◆ setDecaySeconds()
void switchboard::EnvelopeGenerator::setDecaySeconds |
( |
float | decaySeconds | ) |
|
Sets the decay time of the generated envelope.
- Parameters
-
decaySeconds | The new decay time value in seconds. |
◆ setPeakLevel()
void switchboard::EnvelopeGenerator::setPeakLevel |
( |
float | peakLevel | ) |
|
Sets the peak level of the generated envelope (the level reached by attack).
- Parameters
-
peakLevel | The new peak level value in the range of 0.0..1.0. |
◆ setReleaseSeconds()
void switchboard::EnvelopeGenerator::setReleaseSeconds |
( |
float | releaseSeconds | ) |
|
Sets the release time of the generated envelope.
- Parameters
-
releaseSeconds | The new release time value in seconds. |
◆ setSustainLevel()
void switchboard::EnvelopeGenerator::setSustainLevel |
( |
float | sustainLevel | ) |
|
Sets the sustain level of the generated envelope.
- Parameters
-
sustainLevel | The new sustain level value in the range of 0.0..1.0. |
◆ trigger()
void switchboard::EnvelopeGenerator::trigger |
( |
| ) |
|
Trigger the envelope generator.
The generator will start to generate the envelope and maintains sustain level until release() is called.