aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2015-12-24 03:54:37 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2015-12-24 03:54:37 +0300
commita6d750f6fac703a4f5c75861d7f1398737e2d484 (patch)
tree04bf85633c1931438c1b9a755b8afc26c8a7f9c2
parenta2a87f35b03242dcbea91dd74f31abde705e183a (diff)
downloadatracdenc-a6d750f6fac703a4f5c75861d7f1398737e2d484.tar.gz
Some improvements of transient detector
- use one last subblock of previous frame - detect postecho distortion
-rw-r--r--src/transient_detector.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/transient_detector.cpp b/src/transient_detector.cpp
index 49e523d..fb46aad 100644
--- a/src/transient_detector.cpp
+++ b/src/transient_detector.cpp
@@ -36,16 +36,23 @@ void TTransientDetector::HPFilter(const double* in, double* out) {
bool TTransientDetector::Detect(const double* buf) {
- double* rmsPerShortBlock = reinterpret_cast<double*>(alloca(sizeof(double) * NShortBlocks));
+ const uint32_t nBlocksToAnalize = NShortBlocks + 1;
+ double* rmsPerShortBlock = reinterpret_cast<double*>(alloca(sizeof(double) * nBlocksToAnalize));
std::vector<double> filtered(BlockSz);
HPFilter(buf, filtered.data());
- for (uint32_t i = 0; i < NShortBlocks; ++i) {
- rmsPerShortBlock[i] = 19.0 * log10(calculateRMS(&filtered[i * ShortSz], ShortSz));
- if (i && rmsPerShortBlock[i] - rmsPerShortBlock[i - 1] > 10) {
- return true;
+ bool trans = false;
+ rmsPerShortBlock[0] = LastEnergy;
+ for (uint32_t i = 1; i < nBlocksToAnalize; ++i) {
+ rmsPerShortBlock[i] = 19.0 * log10(calculateRMS(&filtered[(i - 1) * ShortSz], ShortSz));
+ if (rmsPerShortBlock[i] - rmsPerShortBlock[i - 1] > 16) {
+ trans = true;
+ }
+ if (rmsPerShortBlock[i - 1] - rmsPerShortBlock[i] > 20) {
+ trans = true;
}
}
- return false;
+ LastEnergy = rmsPerShortBlock[NShortBlocks];
+ return trans;
}
}