OpenShot Library | OpenShotAudio  0.2.2
juce::ADSR Class Reference

A very simple ADSR envelope class. More...

#include <juce_ADSR.h>

Classes

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

Public Member Functions

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.
 
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.
 
void noteOn ()
 Starts the attack phase of the envelope.
 
void noteOff ()
 Starts the release phase of the envelope.
 
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.

Definition at line 40 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 56 of file juce_ADSR.h.

Class Members
float attack Attack time in seconds.
float decay Decay time in seconds.
float sustain Sustain level.
float release Release time in seconds.

Member Function Documentation

◆ 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 78 of file juce_ADSR.h.

References juce::ADSR::Parameters::sustain.

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

◆ getParameters()

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

Returns the parameters currently being used by an ADSR object.

See also
setParameters

Definition at line 93 of file juce_ADSR.h.

◆ 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 103 of file juce_ADSR.h.

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

◆ getNextSample()

float juce::ADSR::getNextSample ( )
inline

Returns the next sample value for an ADSR object.

See also
applyEnvelopeToBuffer

Definition at line 157 of file juce_ADSR.h.

References reset().

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

◆ 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 207 of file juce_ADSR.h.

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


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