TracktionEngine
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tracktion::engine::LinEnvelope Class Reference

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. More...
 
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. More...
 
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. More...
 

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

Enumerator
idle 
attack 
decay 
sustain 
release 

Member Function Documentation

◆ setParameters()

void tracktion::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, tracktion::engine::LinEnvelope::Parameters::sustain, and sustainLevel.

◆ setSampleRate()

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

References sampleRate.

◆ getEnvelopeValue()

float tracktion::engine::LinEnvelope::getEnvelopeValue ( )

References envelopeVal.

◆ getState()

State tracktion::engine::LinEnvelope::getState ( )

References currentState.

◆ noteOn()

void tracktion::engine::LinEnvelope::noteOn ( )

◆ noteOff()

void tracktion::engine::LinEnvelope::noteOff ( )

◆ reset()

void tracktion::engine::LinEnvelope::reset ( )

References currentState, envelopeVal, and idle.

Referenced by getNextSample().

◆ getNextSample()

float tracktion::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 tracktion::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()

void tracktion::engine::LinEnvelope::calculateRates ( const Parameters parameters)
protected

Member Data Documentation

◆ currentState

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

◆ currentParameters

Parameters tracktion::engine::LinEnvelope::currentParameters
protected

Referenced by setParameters().

◆ sampleRate

double tracktion::engine::LinEnvelope::sampleRate = 44100.0
protected

Referenced by calculateRates(), and setSampleRate().

◆ envelopeVal

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

◆ sustainLevel

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

◆ attackRate

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

◆ decayRate

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

◆ releaseRate

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

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