blob: 9302af970f35755bacab0582704e95e74adb1932 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <cmath>
#include "Ptagc.h"
using namespace Pinetime::Controllers;
Ptagc::Ptagc(float start, float decay, float threshold) : peak{start}, decay{decay}, boost{1.0f/decay}, threshold{threshold} {
}
float Ptagc::Step(float spl) {
if(std::abs(spl) > peak)
peak *= boost;
else
peak *= decay;
if((spl > (peak * threshold)) || (spl < (peak * -threshold)))
return 0.0f;
spl = 100.0f * spl / (2.0f * peak);
return spl;
}
|