Fast Averaging Envelope Follower
Overview
The Fast Averaging Envelope Follower is a variation of the Fast Envelope Follower. It is a simple composite class that contains a fast envelope follower member and a moving average filter member to smooth out the staircase ripples. One advantage of a moving average filter over a standard low-pass filter is that its output has less distortion of the envelope’s shape due to its linear phase response, which means it does not cause phase shifts, keeping the signal’s time-domain shape substantially intact.
Response
The plot in Figure 1 below shows the fast averaging envelope follower’s response (envelope: pink, signal: blue, absolute value of the signal: dark blue).
The plot in Figure 2 below shows the plain and Fast averaging envelope follower’s response. The fast envelope follower’s staircase-like envelope is effectively smoothed out using a moving average filter with the same duration as the hold
parameter. The moving average filter transforms the hard staircase edges into soft ramps.
Declaration
template <std::size_t div>
struct basic_fast_ave_envelope_follower
{
basic_fast_ave_envelope_follower(duration hold, float sps);
float operator()(float s);
float operator()() const;
};
using fast_ave_envelope_follower = basic_fast_ave_envelope_follower<2>;
basic_fast_ave_envelope_follower
essentially follows the same API as Fast Envelope Follower.
basic_fast_ave_envelope_follower
is a template class parameterized by div
, which must be >= 1. div
specifies the minimum duration required for the hold
parameter. The hold duration should be equal to or slightly longer than 1/div
multiplied by the period of the lowest frequency of the signal we wish to track. For example, if the lowest frequency we wish to track is 440 Hz, and div
= 2, then the hold
parameter should be greater than 1.13 ms.
fast_ave_envelope_follower
is an alias for basic_fast_ave_envelope_follower<2>
. In general, this is all you need to use, unless you want finer granularity. The higher the div
is, the finer the granularity possible. Again, all of these comes at the cost of additional computing complexity.
Expressions
Notation
env_t
-
A
basic_fast_ave_envelope_follower<div>
type. env
,a
,b
-
Objects of type
basic_fast_ave_envelope_follower<div>
hold
-
Object of type
duration
sps
-
Floating point value for samples per second.
s
-
Floating point value for the latest input sample.
Constructors and Assignment
Expression | Semantics |
---|---|
|
Construct a |
|
Copy construct from |
|
Assign |
C++ brace initialization may also be used. |
env_t
is just a shortcut notation for any type or alias to a template instantiation of basic_fast_ave_envelope_follower<div>
. Example:
using my_env_t = basic_fast_ave_envelope_follower<4>;