Loading...
Searching...
No Matches
juce::ADSR Class Reference

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

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().

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

- juce_audio_basics/utilities/juce_ADSR.h

## 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.
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 | setSampleRate (double newSampleRate) noexcept
| Sets the sample rate that will be used for the envelope.
void | reset () noexcept
| Resets the envelope to an idle state.
void | noteOn () noexcept
| Starts the attack phase of the envelope.
void | noteOff () noexcept
| Starts the release phase of the envelope.
float | getNextSample () noexcept
| Returns the next sample value for an ADSR object.
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.

## Constructors and Destructors

## ADSR()

juce::ADSR::ADSR | ( |  | ) |

inline

## Member Functions

## setParameters()

void juce::ADSR::setParameters | ( | const Parameters & | newParameters | ) |

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!

See also
  getParameters

References jassert.

## getParameters()

const Parameters & juce::ADSR::getParameters | ( |  | ) | const

inline noexcept

Returns the parameters currently being used by an ADSR object.

See also
  setParameters

## isActive()

bool juce::ADSR::isActive | ( |  | ) | const

inline noexcept

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

## setSampleRate()

void juce::ADSR::setSampleRate | ( | double | newSampleRate | ) |

inline noexcept

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

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

References jassert.

## reset()

void juce::ADSR::reset | ( |  | ) |

inline noexcept

Resets the envelope to an idle state.

Referenced by noteOff().

## noteOn()

void juce::ADSR::noteOn | ( |  | ) |

inline noexcept

Starts the attack phase of the envelope.

## noteOff()

void juce::ADSR::noteOff | ( |  | ) |

inline noexcept

Starts the release phase of the envelope.

References reset().

## getNextSample()

float juce::ADSR::getNextSample | ( |  | ) |

inline noexcept

Returns the next sample value for an ADSR object.

See also
  applyEnvelopeToBuffer

Referenced by applyEnvelopeToBuffer().

## applyEnvelopeToBuffer()

template<typename FloatType>

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

inline

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

See also
  getNextSample

References juce::AudioBuffer< Type >::applyGain(), juce::AudioBuffer< Type >::clear(), getNextSample(), juce::AudioBuffer< Type >::getNumChannels(), juce::AudioBuffer< Type >::getNumSamples(), juce::AudioBuffer< Type >::getWritePointer(), and jassert.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited