eDSP  0.0.1
A cross-platform DSP library written in C++.
Public Types | Public Member Functions | List of all members
edsp::envelope_follower< T > Class Template Reference

This class implements a basic envelope-follower. More...

#include <envelope_follower.hpp>

Public Types

using value_type = T
 
using size_type = std::size_t
 

Public Member Functions

constexpr envelope_follower (value_type samplerate, value_type attackTime, value_type releaseTime, bool rectify=false) noexcept
 Creates an EnvelopeFollower object class. More...
 
constexpr value_type samplerate () const noexcept
 Returns the sample rate in Hz. More...
 
constexpr void set_samplerate (value_type samplerate) noexcept
 Sets the sample rate in Hz and resets the internal parameters. More...
 
constexpr value_type attack_time () const noexcept
 Returns the attack time of the first order lowpass in the attack phase. More...
 
constexpr void set_attack_time (value_type attackTime) noexcept
 Set the the attack time of the first order lowpass in the attack phase. More...
 
constexpr value_type release_time () const noexcept
 Returns the release time of the first order lowpass in the release phase. More...
 
constexpr void set_release_time (value_type releaseTime) noexcept
 Set the the release time of the first order lowpass in the attack phase. More...
 
constexpr bool rectification () const noexcept
 Checks if the rectification is enabled. More...
 
constexpr void set_rectification (bool enabled) noexcept
 Enables the rectification of the output signal. More...
 
constexpr void reset () noexcept
 Resets the temporal an internal data. More...
 
template<typename InIterator , typename OutputIt >
constexpr void apply (InIterator first, InIterator last, OutputIt d_first)
 Computes the envelope of the element's value in the range [first, last), and stores the result in another range, beginning at d_first. More...
 

Detailed Description

template<typename T>
class edsp::envelope_follower< T >

This class implements a basic envelope-follower.

The envelope follower takes an high-frequency signal as input and provides an output which is the envelope of the original signal. It is frequently used to detect the amplitude variations of an incoming signal to produce a control signal that resembles those variations.

This class implements a basic Envelope Follower based in a non-symmetric lowpass filter. The output of a low-pass filter can be viewed as a moving average of its input. A minimal envelope generator has an attack period, in which the level of the envelope rises from an initial zero level to a maximum level, followed by a release phase,in which the level falls back to zero. *

Member Typedef Documentation

◆ size_type

template<typename T>
using edsp::envelope_follower< T >::size_type = std::size_t

◆ value_type

template<typename T>
using edsp::envelope_follower< T >::value_type = T

Constructor & Destructor Documentation

◆ envelope_follower()

template<typename T >
constexpr edsp::envelope_follower< T >::envelope_follower ( value_type  samplerate,
value_type  attackTime,
value_type  releaseTime,
bool  rectify = false 
)
noexcept

Creates an EnvelopeFollower object class.

Parameters
samplerateThe sample rate in Hz.
attackTimeThe attack time of the first order lowpass in the attack phase in msecs.
releaseTimeThe release time of the first order lowpass in the attack phase in msecs.
rectifyIf true, enables the rectification of the output signal.

Member Function Documentation

◆ apply()

template<typename T >
template<typename InIterator , typename OutputIt >
constexpr void edsp::envelope_follower< T >::apply ( InIterator  first,
InIterator  last,
OutputIt  d_first 
)

Computes the envelope of the element's value in the range [first, last), and stores the result in another range, beginning at d_first.

Parameters
firstInput iterator defining the beginning of the input range.
lastInput iterator defining the ending of the input range.
d_firstOutput iterator defining the beginning of the destination range.

◆ attack_time()

template<typename T >
constexpr envelope_follower< T >::value_type edsp::envelope_follower< T >::attack_time ( ) const
noexcept

Returns the attack time of the first order lowpass in the attack phase.

Returns
Attack time in msecs.

◆ rectification()

template<typename T >
constexpr bool edsp::envelope_follower< T >::rectification ( ) const
noexcept

Checks if the rectification is enabled.

Returns
true if the rectification is enabled, false otherwise.

◆ release_time()

template<typename T >
constexpr envelope_follower< T >::value_type edsp::envelope_follower< T >::release_time ( ) const
noexcept

Returns the release time of the first order lowpass in the release phase.

Returns
Release time in msecs.

◆ reset()

template<typename T >
constexpr void edsp::envelope_follower< T >::reset ( )
noexcept

Resets the temporal an internal data.

◆ samplerate()

template<typename T >
constexpr envelope_follower< T >::value_type edsp::envelope_follower< T >::samplerate ( ) const
noexcept

Returns the sample rate in Hz.

Returns
Sample rate in Hz.

◆ set_attack_time()

template<typename T >
constexpr void edsp::envelope_follower< T >::set_attack_time ( value_type  attackTime)
noexcept

Set the the attack time of the first order lowpass in the attack phase.

Parameters
attackTimeAttack time in msecs.

◆ set_rectification()

template<typename T >
constexpr void edsp::envelope_follower< T >::set_rectification ( bool  enabled)
noexcept

Enables the rectification of the output signal.

If the rectification is enabled, the envelope-follower is based on the absolute value of signal

Parameters
enabledState of the rectification.

◆ set_release_time()

template<typename T >
constexpr void edsp::envelope_follower< T >::set_release_time ( value_type  releaseTime)
noexcept

Set the the release time of the first order lowpass in the attack phase.

Parameters
releaseTimeRelease time in msecs.

◆ set_samplerate()

template<typename T >
constexpr void edsp::envelope_follower< T >::set_samplerate ( value_type  samplerate)
noexcept

Sets the sample rate in Hz and resets the internal parameters.

Parameters
samplerateSample rate in Hz.

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