diff --git a/app/build.gradle b/app/build.gradle index 2e5dbe5..7c9c45c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "at.lockstep" minSdk 24 targetSdk 34 - versionCode 10003 - versionName "1.0.3" + versionCode 10004 + versionName "1.0.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 62815a2..cd93dfd 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -35,7 +35,6 @@ add_library(${CMAKE_PROJECT_NAME} SHARED jni_mpg123.cpp jni_lockstep.cpp jni_stepdetector.cpp - StepDetector.cpp ) find_package (oboe REQUIRED CONFIG) diff --git a/app/src/main/cpp/StepDetector.cpp b/app/src/main/cpp/StepDetector.cpp deleted file mode 100644 index aebfe41..0000000 --- a/app/src/main/cpp/StepDetector.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// Created by david on 03.03.2026. -// - -#include "StepDetector.h" - -// TODO: repeated code in libpasada. We could use the StepDetector class from there in jni_stepdetector.cpp - -// TODO: we are hardcoding filter coefficients for 60 Hz -// TODO: this is tolerable for 50 Hz - -// TODO: check if we can do with floats instead of doubles -// (check how much the [already bad] accuracy of filtering suffers) - -// TODO: in Java, check if delta timestamps effectively match FPS -// TODO: FPS constant should be passed as argument to C++ (but we keep an FPS define to validate the coefficients) - -// Butterworth filter: order=5, fc=0.5, fs=60, btype='highpass' -static std::vector hpf_taps_b {0.91875845, -4.59379227, 9.18758454, -9.18758454, 4.59379227, -0.91875845}; -static std::vector hpf_taps_a {1. , -4.83056552, 9.33652742, -9.02545247, 4.36360803, -0.8441171}; -static size_t upslope_width = 4; -const size_t len_refr = (size_t) (FPS / (MAX_BPM / 60)); - -StepDetector::StepDetector(StepListener *listener) : - listener(listener), - f_highpass(hpf_taps_b, hpf_taps_a), - f_neg(1, 0, 0, std::vector {-1.0}), - f_ssf(upslope_width), - f_ssd(len_refr), - f_sqi(upslope_width) -{} - -#if (FPS != 60) -#error "FPS must currently be 60, as highpass taps are pre-computed for that value" -#endif - -void StepDetector::filter(std::vector values) { - // TODO: later on, we should use a vector projection towards gravity - auto s0 = (double) values[1]; // take y-axis value for now - auto s1 = f_highpass.filter(s0); - auto s2 = f_neg.filter(s1); - auto s3 = f_ssf.filter(s2); - auto s4 = f_ssd.filter(s3); - auto q5 = f_sqi.filter(s2, s3, s4); - // is step, step quality is OK, and we have a listener? - if(s4 > 0.0 && q5 > 0.0 && listener != nullptr) { - listener->playBeat(); - } -} diff --git a/app/src/main/cpp/StepDetector.h b/app/src/main/cpp/StepDetector.h deleted file mode 100644 index 66145dd..0000000 --- a/app/src/main/cpp/StepDetector.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Created by david on 03.03.2026. -// - -#ifndef LOCKSTEP_STEPDETECTOR_H -#define LOCKSTEP_STEPDETECTOR_H - -#include "StepListener.h" -#include "iir_filter.h" -#include "ssf_filter.h" -#include - -class StepDetector { -protected: - StepListener *listener; - IirFilter f_highpass; - Filt f_neg; - SsfFilter f_ssf; - SsfStepDetector f_ssd; - RunningQualityFilter f_sqi; - -public: - StepDetector(StepListener *listener); - void filter(std::vector values); -}; - -#endif //LOCKSTEP_STEPDETECTOR_H diff --git a/app/src/main/cpp/jni_stepdetector.cpp b/app/src/main/cpp/jni_stepdetector.cpp index 7f6a98d..6984141 100644 --- a/app/src/main/cpp/jni_stepdetector.cpp +++ b/app/src/main/cpp/jni_stepdetector.cpp @@ -3,7 +3,7 @@ // #include -#include "StepDetector.h" +#include "step_detector.h" #include #include @@ -26,7 +26,7 @@ Java_at_lockstep_filter_StepDetector_native_1create( jclass /*unused*/, jlong engineHandle) { auto *listener = reinterpret_cast(engineHandle); // We use std::nothrow so `new` returns a nullptr if the engine creation fails - auto *detector = new(std::nothrow) StepDetector(listener); + auto *detector = new(std::nothrow) StepDetector(60.0 /* FPS */, listener); // TODO return reinterpret_cast(detector); } diff --git a/app/src/main/cpp/libpasada b/app/src/main/cpp/libpasada index b919e84..b333712 160000 --- a/app/src/main/cpp/libpasada +++ b/app/src/main/cpp/libpasada @@ -1 +1 @@ -Subproject commit b919e845c791069e8be9f8c6db299db53ddf1ac4 +Subproject commit b333712d9c9e1a7e41183b7794cc39ef64dd4612