-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add Puara TouchArrayGestureDetector processor #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yrevash
wants to merge
2
commits into
ossia:master
Choose a base branch
from
yrevash:feature/puara-toucharray-processor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include "TouchArrayAvnd.hpp" | ||
|
|
||
| namespace puara_gestures::objects | ||
| { | ||
|
|
||
| void TouchArrayAvnd::operator()() | ||
| { | ||
| // 1. Getting input touch array and its size | ||
| // Useing .value here as std::vector doesn't have an implicit conversion from halp::val_port | ||
| std::vector<int>& current_touch_array_data = inputs.touch_array_input.value; | ||
| const int touch_size = static_cast<int>(current_touch_array_data.size()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really necessary - you could rename the array "touch" and then do "touch.size()" throughout, it's not going to have any performance impact due to inlining |
||
|
|
||
| if(touch_size == 0 || touch_size < 2 * TAGD_TOUCH_SIZE_EDGE) | ||
| { | ||
| outputs.total_touch_avg.value = 0.0f; | ||
| outputs.top_touch_avg.value = 0.0f; | ||
| outputs.middle_touch_avg.value = 0.0f; | ||
| outputs.bottom_touch_avg.value = 0.0f; | ||
| outputs.total_brush.value = 0.0f; | ||
| outputs.total_rub.value = 0.0f; | ||
| return; | ||
| } | ||
| impl.update(current_touch_array_data.data(), touch_size); | ||
|
|
||
| outputs.total_touch_avg.value = impl.totalTouchAverage; | ||
| outputs.top_touch_avg.value = impl.topTouchAverage; | ||
| outputs.middle_touch_avg.value = impl.middleTouchAverage; | ||
| outputs.bottom_touch_avg.value = impl.bottomTouchAverage; | ||
| outputs.total_brush.value = impl.totalBrush; | ||
| outputs.total_rub.value = impl.totalRub; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #pragma once | ||
|
|
||
| #include <halp/audio.hpp> | ||
| #include <halp/controls.hpp> | ||
| #include <halp/mappers.hpp> | ||
| #include <halp/meta.hpp> | ||
| #include <puara/descriptors/touchArrayGestureDetector.h> | ||
|
|
||
| #include <ratio> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| constexpr int TAGD_MAX_BLOBS = 3; | ||
| constexpr int TAGD_TOUCH_SIZE_EDGE = 2; | ||
|
|
||
| namespace puara_gestures::objects | ||
| { | ||
|
|
||
| class TouchArrayAvnd | ||
| { | ||
| public: | ||
| halp_meta(name, "Touch Array Gestures") | ||
| halp_meta(category, "Gestures") | ||
| halp_meta(c_name, "puara_touch_array_avnd") | ||
| halp_meta( | ||
| description, | ||
| "Detects touch averages, brush, and rub gestures from a linear touch array input.") | ||
| halp_meta( | ||
| manual_url, | ||
| "https://github.com/Puara/puara-gestures/blob/main/include/puara/descriptors/" | ||
| "touchArrayGestureDetector.h") | ||
| halp_meta(uuid, "9d09a014-1f61-4051-97e6-aa9971a616e9") | ||
|
|
||
| struct ins | ||
| { | ||
| halp::val_port<"Touch Array", std::vector<int>> touch_array_input; | ||
| halp::knob_f32<"Brush/Rub Integrator Leak", halp::range{0.0, 1.0, 0.7}> | ||
| common_integrator_leak; | ||
| struct CommonIntegratorFreqParam | ||
| : halp::knob_f32< | ||
| "Brush/Rub Integrator Freq (Hz)", halp::range{1.0, 200.0, 100.0f}> | ||
| { | ||
| using mapper = halp::log_mapper<std::ratio<85, 100>>; | ||
| } common_integrator_frequency; | ||
|
|
||
| } inputs; | ||
|
|
||
| struct outputs | ||
| { | ||
| halp::val_port<"Total Touch Avg", float> total_touch_avg{0.0f}; | ||
| halp::val_port<"Top Touch Avg", float> top_touch_avg{0.0f}; | ||
| halp::val_port<"Middle Touch Avg", float> middle_touch_avg{0.0f}; | ||
| halp::val_port<"Bottom Touch Avg", float> bottom_touch_avg{0.0f}; | ||
|
|
||
| halp::val_port<"Total Brush", float> total_brush{0.0f}; | ||
| halp::val_port<"Total Rub", float> total_rub{0.0f}; | ||
|
|
||
| } outputs; | ||
|
|
||
| void operator()(); | ||
|
|
||
| puara_gestures::TouchArrayGestureDetector<TAGD_MAX_BLOBS, TAGD_TOUCH_SIZE_EDGE> impl; | ||
|
|
||
| float m_prev_common_integrator_leak{-1.f}; | ||
| int m_prev_common_integrator_frequency{-1}; | ||
| }; | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd mark this as
const auto&insteadUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jcelerier ,
"Regarding the const auto& suggestion for current_touch_array_data (renamed to touch_data):
When I applied const auto&, touch_data.data() returns a const int*. However, the TouchArrayGestureDetector::update function is defined as
void update(int* touchArray, int touchSize)Therefore, the most const-correct solution would be to update the TouchArrayGestureDetector::update signature in puara/descriptors/touchArrayGestureDetector.h to:
void update(const int* touchArray, int touchSize);Should I proceed with this change and commit? Or should I keep the default implementation as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jcelerier,
As I mentioned, I think modifying
ToughArrayGestures.his a valid option as TouchArrayGestureDetector::update function does not modify the touchArray data it receives. It only reads from it (via arrayAverage and blobDetector.detect1D).Thus, it would be a good choice to change the call from
-->
void update(int* touchArray, int touchSize)to this
-->
void update(const int* touchArray, int touchSize);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we'd use std::span