OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::ADSR Class Reference

`#include <juce_ADSR.h>`

## Classes
struct | Parameters

## Public Member Functions
void | setParameters (const Parameters &newParameters)
const Parameters & | getParameters () const
bool | isActive () const noexcept
void | setSampleRate (double sampleRate)
void | reset ()
void | noteOn ()
void | noteOff ()
float | getNextSample ()
template<typename FloatType >
void | applyEnvelopeToBuffer (AudioBuffer< FloatType > &buffer, int startSample, int numSamples)

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

Definition at line 36 of file juce_ADSR.h.

## Class Documentation

## ◆ juce::ADSR::Parameters

struct juce::ADSR::Parameters

Holds the parameters being used by an ADSR object.

Definition at line 52 of file juce_ADSR.h.

Class Members
float | attack = 0.1f | Attack time in seconds.
float | decay = 0.1f | Decay time in seconds.
float | release = 0.1f | Release time in seconds.
float | sustain = 1.0f | Sustain level.

## Constructor & Destructor Documentation

## ◆ ADSR()

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

Definition at line 40 of file juce_ADSR.h.

## Member Function Documentation

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

Definition at line 203 of file juce_ADSR.h.

## ◆ getNextSample()

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

Returns the next sample value for an ADSR object.

See also
  applyEnvelopeToBuffer

Definition at line 153 of file juce_ADSR.h.

Referenced by applyEnvelopeToBuffer(), and juce::SamplerVoice::renderNextBlock().

## ◆ getParameters()

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

Returns the parameters currently being used by an ADSR object.

See also
  setParameters

Definition at line 89 of file juce_ADSR.h.

## ◆ isActive()

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

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

Definition at line 92 of file juce_ADSR.h.

## ◆ noteOff()

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

Starts the release phase of the envelope.

Definition at line 132 of file juce_ADSR.h.

Referenced by juce::SamplerVoice::stopNote().

## ◆ noteOn()

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

Starts the attack phase of the envelope.

Definition at line 114 of file juce_ADSR.h.

Referenced by juce::SamplerVoice::startNote().

## ◆ reset()

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

Resets the envelope to an idle state.

Definition at line 107 of file juce_ADSR.h.

Referenced by getNextSample(), noteOff(), and juce::SamplerVoice::stopNote().

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

Definition at line 74 of file juce_ADSR.h.

Referenced by juce::SamplerVoice::startNote().

## ◆ setSampleRate()

void juce::ADSR::setSampleRate | ( | double | sampleRate | ) |
| inline

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

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

Definition at line 99 of file juce_ADSR.h.

Referenced by juce::SamplerVoice::startNote().

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

- juce_ADSR.h