A very simple ADSR envelope class. More...
#include <juce_ADSR.h>

Classes | |
| struct | Parameters |
| Holds the parameters being used by an ADSR object. More... | |
Public Member Functions | |
| ADSR () | |
| template<typename FloatType > | |
| void | applyEnvelopeToBuffer (AudioBuffer< FloatType > &buffer, int startSample, int numSamples) |
| This method will conveniently apply the next numSamples number of envelope values to an AudioBuffer. | |
| float | getNextSample () noexcept |
| Returns the next sample value for an ADSR object. | |
| const Parameters & | getParameters () const noexcept |
| Returns the parameters currently being used by an ADSR object. | |
| bool | isActive () const noexcept |
| Returns true if the envelope is in its attack, decay, sustain or release stage. | |
| void | noteOff () noexcept |
| Starts the release phase of the envelope. | |
| void | noteOn () noexcept |
| Starts the attack phase of the envelope. | |
| void | reset () noexcept |
| Resets the envelope to an idle state. | |
| void | setParameters (const Parameters &newParameters) |
| Sets the parameters that will be used by an ADSR object. | |
| void | setSampleRate (double newSampleRate) noexcept |
| Sets the sample rate that will be used for the envelope. | |
Private Types | |
| enum class | State { idle , attack , decay , sustain , release } |
Private Member Functions | |
| void | goToNextState () noexcept |
| void | recalculateRates () noexcept |
Private Attributes | |
| float | attackRate = 0.0f |
| float | decayRate = 0.0f |
| float | envelopeVal = 0.0f |
| Parameters | parameters |
| float | releaseRate = 0.0f |
| double | sampleRate = 44100.0 |
| State | state = State::idle |
A very simple ADSR envelope class.
To use it, call setSampleRate() with the current sample rate and give it some parameters with setParameters() then call getNextSample() to get the envelope value to be applied to each audio sample or applyEnvelopeToBuffer() to apply the envelope to a whole buffer.
Do not change the parameters during playback. If you change the parameters before the release stage has completed then you must call reset() before the next call to noteOn().
@tags{Audio}
|
strongprivate |
|
inline |
|
inline |
This method will conveniently apply the next numSamples number of envelope values to an AudioBuffer.
References jassert.
|
inlinenoexcept |
Returns the next sample value for an ADSR object.
|
inlinenoexcept |
Returns the parameters currently being used by an ADSR object.
|
inlineprivatenoexcept |
|
inlinenoexcept |
Returns true if the envelope is in its attack, decay, sustain or release stage.
|
inlinenoexcept |
Starts the release phase of the envelope.
|
inlinenoexcept |
Starts the attack phase of the envelope.
|
inlineprivatenoexcept |
|
inlinenoexcept |
Resets the envelope to an idle state.
|
inline |
Sets the parameters that will be used by an ADSR object.
You must have called setSampleRate() with the correct sample rate before this otherwise the values may be incorrect!
References jassert.
|
inlinenoexcept |
Sets the sample rate that will be used for the envelope.
This must be called before the getNextSample() or setParameters() methods.
References jassert.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |