JUCE
Classes | Public Member Functions | List of all members
ADSR Class Reference

A very simple ADSR envelope class. More...

Classes

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

Public Member Functions

 ADSR ()
 
void setParameters (const Parameters &newParameters)
 Sets the parameters that will be used by an ADSR object. More...
 
const ParametersgetParameters () const
 Returns the parameters currently being used by an ADSR object. More...
 
bool isActive () const noexcept
 Returns true if the envelope is in its attack, decay, sustain or release stage. More...
 
void setSampleRate (double sampleRate)
 Sets the sample rate that will be used for the envelope. More...
 
void reset ()
 Resets the envelope to an idle state. More...
 
void noteOn ()
 Starts the attack phase of the envelope. More...
 
void noteOff ()
 Starts the release phase of the envelope. More...
 
float getNextSample ()
 Returns the next sample value for an ADSR object. More...
 
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. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ADSR()

ADSR::ADSR ( )

References setParameters(), and setSampleRate().

Member Function Documentation

◆ setParameters()

void ADSR::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 ADSR::Parameters::sustain.

Referenced by ADSR().

◆ getParameters()

const Parameters& ADSR::getParameters ( ) const

Returns the parameters currently being used by an ADSR object.

See also
setParameters

◆ isActive()

bool ADSR::isActive ( ) const
noexcept

Returns true if the envelope is in its attack, decay, sustain or release stage.

◆ setSampleRate()

void ADSR::setSampleRate ( double  sampleRate)

Sets the sample rate that will be used for the envelope.

This must be called before the getNextSample() or setParameters() methods.

References jassert.

Referenced by ADSR().

◆ reset()

void ADSR::reset ( )

Resets the envelope to an idle state.

Referenced by applyEnvelopeToBuffer(), getNextSample(), and noteOff().

◆ noteOn()

void ADSR::noteOn ( )

Starts the attack phase of the envelope.

◆ noteOff()

void ADSR::noteOff ( )

Starts the release phase of the envelope.

References reset().

◆ getNextSample()

float ADSR::getNextSample ( )

Returns the next sample value for an ADSR object.

See also
applyEnvelopeToBuffer

References reset().

Referenced by applyEnvelopeToBuffer().

◆ applyEnvelopeToBuffer()

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

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