feat: StepDetector
move StepDetector from lockstep android to libpasada
This commit is contained in:
@@ -9,10 +9,11 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} libnpy/inclu
|
||||
# 'Google_Tests_run' is the target name
|
||||
# 'test1.cpp test2.cpp' are source files with tests
|
||||
add_executable(Google_Tests_run
|
||||
test_helpers.cpp
|
||||
test1.cpp
|
||||
test2.cpp
|
||||
test3.cpp
|
||||
test_helpers.cpp
|
||||
test4.cpp
|
||||
)
|
||||
|
||||
file(COPY test1/data1.npy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test1)
|
||||
@@ -26,6 +27,8 @@ file(COPY test2/ssf_t2_y_ref.npy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test2)
|
||||
|
||||
file(COPY test3/ssf_t3_acc.npy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test3)
|
||||
|
||||
file(COPY test4/step_150a.npy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test4)
|
||||
|
||||
target_link_libraries(Google_Tests_run pasada)
|
||||
#target_include_directories(Google_Tests_run PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/pasada-lib/include")
|
||||
|
||||
|
||||
38
google-tests/test4.cpp
Normal file
38
google-tests/test4.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Created by david on 15.03.2026.
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "step_detector.h"
|
||||
#include "npy.hpp"
|
||||
#include "test_helpers.h"
|
||||
|
||||
TEST(StepDetector, t1_sub_sample_resolution) {
|
||||
npy::npy_data s = npy::read_npy<double>("test4/step_150a.npy");
|
||||
|
||||
std::vector<double> signal = fetch_y_axis(s);
|
||||
const size_t N = signal.size();
|
||||
const size_t N_INIT = SsfStepDetector::initial_samples();
|
||||
|
||||
StepDetector det(nullptr, true);
|
||||
|
||||
// initialize: feed for priming the filters
|
||||
det.primeFilters(signal);
|
||||
|
||||
// feed for actual test
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
const auto a_i = static_cast<float>(signal[i]);
|
||||
det.filter(std::vector<float> {0.0f, a_i, 0.0f});
|
||||
}
|
||||
|
||||
std::vector<double> ssd = det.getBufSsd(); // raw SsfStepDetector
|
||||
std::vector<double> sqi = det.getBufSqi(); // SQI - RunningQuality beat correlations
|
||||
std::vector<double> out = det.getBufOut(); // steps where SQI is OK
|
||||
|
||||
npy_save("test4/t1_ssd.npy", ssd);
|
||||
npy_save("test4/t1_sqi.npy", sqi);
|
||||
npy_save("test4/t1_out.npy", out);
|
||||
|
||||
// http://localhost:8888/notebooks/2026-03-10%20step%20interpolate%2F2026-03-15%20synth.ipynb
|
||||
}
|
||||
BIN
google-tests/test4/step_150.npy
Normal file
BIN
google-tests/test4/step_150.npy
Normal file
Binary file not shown.
BIN
google-tests/test4/step_150a.npy
Normal file
BIN
google-tests/test4/step_150a.npy
Normal file
Binary file not shown.
Reference in New Issue
Block a user