54 int numberOfFragments = amplitude.size();
60 while (j < numberOfFragments) {
62 uint16_t amp[2] = {0, 0};
63 for (
int i = 0; i < 2; i++) { amp[i] = (
BODY_AMPLITUDE << 12) | amplitude[i + j]; }
76 int numberOfSamplings = amplitude.size();
80 for (
int i = 0; i < numberOfSamplings; i++) {
81 if (amplitude[i] >
max) {
88 if (maxIndex < 0 || maxIndex >= numberOfSamplings)
return charge;
93 else if (maxIndex == (numberOfSamplings - 1))
94 return amplitude[numberOfSamplings - 1];
97 double y1 = amplitude[maxIndex - 1];
98 double y2 = amplitude[maxIndex];
99 double y3 = amplitude[maxIndex + 1];
100 a = 0.5 * (y3 + y1 - 2 * y2);
106 double offset = (
a == 0) ? 0 : -b / (2 *
a);
107 charge =
static_cast<int>(
a * offset * offset + b * offset + c - amplitude[0]);
108 time = (maxIndex + offset) * samplingTime;