diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-03-13 09:49:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-09-02 21:21:28 +0300 |
commit | cfaa2cd39b7256a868a4f5cd83aac207df6bd1b3 (patch) | |
tree | 75efff26584e046566d17cd308d45b6b0fd5abfc /src/transient_detector_ut.cpp | |
parent | b4df8a7c2dd12eea27c8cc52bd52a1bb8c00943f (diff) | |
download | atracdenc-cfaa2cd39b7256a868a4f5cd83aac207df6bd1b3.tar.gz |
Dirty implementation of atrac3 encoder:
- no JS mode
- constant quantiser for tonal components
- gain controll implemented but produces some artifacts with real signals.
- etc...
Diffstat (limited to 'src/transient_detector_ut.cpp')
-rw-r--r-- | src/transient_detector_ut.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/transient_detector_ut.cpp b/src/transient_detector_ut.cpp new file mode 100644 index 0000000..5c018c3 --- /dev/null +++ b/src/transient_detector_ut.cpp @@ -0,0 +1,36 @@ +#include "transient_detector.h" +#include <gtest/gtest.h> + +#include <vector> +#include <cmath> + +using std::vector; +using namespace NAtracDEnc; +TEST(AnalyzeGain, AnalyzeGainSimple) { + + TFloat in[256]; + for (int i = 0; i < 256; ++i) { + if (i <= 24) { + in[i] = 1.0; + } else if ( i > 24 && i <= 32) { + in[i] = 8.0; + } else if ( i > 32 && i <= 66) { + in[i] = 128.0; + } else { + in[i] = 0.5; + } + } + vector<TFloat> res = AnalyzeGain(in, 256, 32, false); + EXPECT_EQ(res.size(), 32); + +// for (TFloat v : res) +// std::cout << v << std::endl; + for (int i = 0; i < 3; ++i) + EXPECT_EQ(res[i], 1.0); + for (int i = 3; i < 4; ++i) + EXPECT_EQ(res[i], 8.0); + for (int i = 4; i < 9; ++i) + EXPECT_EQ(res[i], 128.0); + for (int i = 9; i < 32; ++i) + EXPECT_EQ(res[i], 0.5); +} |