diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-07-08 21:42:48 +0000 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-07-09 23:07:40 +0200 |
commit | c4b19af8391640f143aaf446658354dcf01432d1 (patch) | |
tree | 68ebb11f38eaec53e16879e59ce776bd249d8491 /src/transient_detector.cpp | |
parent | f8eabde1e1a2fa6bdb2b09dcdee5cecb750beb30 (diff) | |
download | atracdenc-c4b19af8391640f143aaf446658354dcf01432d1.tar.gz |
Allow to configure atracdenc to use float instead of double
The default is double for hystorical reason.
Actually no any reason to use double precision float point
calculation for all processing. AT3P encoding will use float
except places were we really need double precision.
So this default will be changed to float in near future and
this option will be removed.
Diffstat (limited to 'src/transient_detector.cpp')
-rw-r--r-- | src/transient_detector.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/transient_detector.cpp b/src/transient_detector.cpp index 8e4c072..ca96cd4 100644 --- a/src/transient_detector.cpp +++ b/src/transient_detector.cpp @@ -51,18 +51,18 @@ void TTransientDetector::HPFilter(const TFloat* in, TFloat* out) { -3.36639e-17 * 2.0, -0.0438162 * 2.0, -1.54175e-17 * 2.0, 0.0931738 * 2.0, -5.52212e-17 * 2.0, -0.313819 * 2.0 }; - memcpy(HPFBuffer.data() + PrevBufSz, in, BlockSz * sizeof(double)); - const double* inBuf = HPFBuffer.data(); + memcpy(HPFBuffer.data() + PrevBufSz, in, BlockSz * sizeof(TFloat)); + const TFloat* inBuf = HPFBuffer.data(); for (size_t i = 0; i < BlockSz; ++i) { - double s = inBuf[i + 10]; - double s2 = 0; + TFloat s = inBuf[i + 10]; + TFloat s2 = 0; for (size_t j = 0; j < ((FIRLen - 1) / 2) - 1 ; j += 2) { s += fircoef[j] * (inBuf[i + j] + inBuf[i + FIRLen - j]); s2 += fircoef[j + 1] * (inBuf[i + j + 1] + inBuf[i + FIRLen - j - 1]); } out[i] = (s + s2)/2; } - memcpy(HPFBuffer.data(), in + (BlockSz - PrevBufSz), PrevBufSz * sizeof(double)); + memcpy(HPFBuffer.data(), in + (BlockSz - PrevBufSz), PrevBufSz * sizeof(TFloat)); } |