WE Core
Loading...
Searching...
No Matches
AREnvelopeFollowerSquareLaw.h
Go to the documentation of this file.
1/*
2 * File: AREnveloperFollowerSquareLaw.h
3 *
4 * Created: 17/11/2020
5 *
6 * This file is part of WECore.
7 *
8 * WECore is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * WECore is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with WECore. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "General/CoreMath.h"
27
28namespace WECore::AREnv {
33 public:
34
36 virtual ~AREnvelopeFollowerSquareLaw() override = default;
37
46 virtual double _envGetNextOutputImpl(double inSample) override {
47 const double tmp = inSample * inSample;
48
49 if (tmp > _envVal)
50 {
51 _envVal = _attackCoef * (_envVal - tmp) + tmp;
52 }
53 else
54 {
55 _envVal = _releaseCoef * (_envVal - tmp) + tmp;
56 }
57
58 return std::sqrt(_envVal);
59 }
60 };
61}
virtual ~AREnvelopeFollowerSquareLaw() override=default
virtual double _envGetNextOutputImpl(double inSample) override