aboutsummaryrefslogtreecommitdiffstats
path: root/src/transient_detector.h
blob: b3db6bae21777694fead4ff43a4ce8ea62887de2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include <math.h>
#include <cstdint>
#include <vector>

namespace NAtracDEnc {
class TTransientDetector {
    const uint32_t ShortSz;
    const uint32_t BlockSz;
    const uint32_t NShortBlocks;
    static const uint32_t PrevBufSz = 20;
    static const uint32_t FIRLen = 21;
    void HPFilter(const double* in, double* out);
    std::vector<double> HPFBuffer;
    double LastEnergy = 0.0;
public:
    TTransientDetector(uint32_t shortSz, uint32_t blockSz)
        : ShortSz(shortSz)
        , BlockSz(blockSz)
        , NShortBlocks(blockSz/shortSz)
    {
        HPFBuffer.resize(BlockSz + FIRLen); 
    }
    bool Detect(const double* buf);
};
}