TracktionEngine
Loading...
Searching...
No Matches
engine::LinEnvelope Class Reference

#include <tracktion_Envelope.h>

Classes

struct  Parameters
 Holds the parameters being used by an ADSR object. More...

Public Types

enum class  State {
  idle , attack , decay , sustain ,
  release
}

Public Member Functions

void setParameters (const Parameters &newParameters)
 Sets the parameters that will be used by an ADSR object.
void setSampleRate (double sr)
float getEnvelopeValue ()
State getState ()
void noteOn ()
void noteOff ()
void reset ()
float getNextSample ()
 Returns the next sample value for an ADSR object.
template<typename FloatType>
void applyEnvelopeToBuffer (juce::AudioBuffer< FloatType > &buffer, int startSample, int numSamples)
 This method will conveniently apply the next numSamples number of envelope values to an AudioBuffer.

Protected Member Functions

void calculateRates (const Parameters &parameters)

Protected Attributes

State currentState = State::idle
Parameters currentParameters
double sampleRate = 44100.0
float envelopeVal = 0.0f
float sustainLevel = 0.0f
float attackRate = 0.0f
float decayRate = 0.0f
float releaseRate = 0.0f

Member Enumeration Documentation

◆ State

enum class engine::LinEnvelope::State
strong
Enumerator
idle 
attack 
decay 
sustain 
release 

Member Function Documentation

◆ setParameters()

void engine::LinEnvelope::setParameters ( const Parameters & newParameters)

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!

See also
getParameters

References calculateRates(), currentParameters, engine::LinEnvelope::Parameters::sustain, and sustainLevel.

◆ setSampleRate()

void engine::LinEnvelope::setSampleRate ( double sr)

References sampleRate.

◆ getEnvelopeValue()

float engine::LinEnvelope::getEnvelopeValue ( )

References envelopeVal.

◆ getState()

State engine::LinEnvelope::getState ( )

References currentState.

◆ noteOn()

void engine::LinEnvelope::noteOn ( )

◆ noteOff()

void engine::LinEnvelope::noteOff ( )

◆ reset()

void engine::LinEnvelope::reset ( )

References currentState, envelopeVal, and idle.

Referenced by getNextSample().

◆ getNextSample()

float engine::LinEnvelope::getNextSample ( )

Returns the next sample value for an ADSR object.

See also
applyEnvelopeToBuffer

References attack, attackRate, currentState, decay, decayRate, envelopeVal, idle, release, releaseRate, reset(), sustain, and sustainLevel.

Referenced by applyEnvelopeToBuffer().

◆ applyEnvelopeToBuffer()

template<typename FloatType>
void engine::LinEnvelope::applyEnvelopeToBuffer ( juce::AudioBuffer< FloatType > & buffer,
int startSample,
int numSamples )

This method will conveniently apply the next numSamples number of envelope values to an AudioBuffer.

See also
getNextSample

References getNextSample().

◆ calculateRates()

Member Data Documentation

◆ currentState

State engine::LinEnvelope::currentState = State::idle
protected

◆ currentParameters

Parameters engine::LinEnvelope::currentParameters
protected

Referenced by setParameters().

◆ sampleRate

double engine::LinEnvelope::sampleRate = 44100.0
protected

Referenced by calculateRates(), and setSampleRate().

◆ envelopeVal

float engine::LinEnvelope::envelopeVal = 0.0f
protected

◆ sustainLevel

float engine::LinEnvelope::sustainLevel = 0.0f
protected

◆ attackRate

float engine::LinEnvelope::attackRate = 0.0f
protected

◆ decayRate

float engine::LinEnvelope::decayRate = 0.0f
protected

◆ releaseRate

float engine::LinEnvelope::releaseRate = 0.0f
protected

The documentation for this class was generated from the following file: