Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ avnd_score_plugin_add(
SOURCES
Puara/LeakyIntegratorAvnd.hpp
Puara/LeakyIntegratorAvnd.cpp
TARGET puara_leaky_integrator
TARGET puara_leaky_integrator
MAIN_CLASS LeakyIntegratorAvnd
NAMESPACE puara_gestures::objects
)
Expand Down Expand Up @@ -163,6 +163,15 @@ avnd_score_plugin_add(
avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES

Puara/TouchArrayAvnd.hpp
Puara/TouchArrayAvnd.hpp
TARGET puara_touch_avnd
MAIN_CLASS TouchArrayAvnd
NAMESPACE puara_gestures::objects
)


Puara/Jab3D_Avnd.hpp
Puara/Jab3D_Avnd.cpp
TARGET puara_jab_3d_avnd
Expand All @@ -180,6 +189,7 @@ avnd_score_plugin_add(
MAIN_CLASS Jab2D_Avnd
NAMESPACE puara_gestures::objects
)

avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES
Expand Down
33 changes: 33 additions & 0 deletions Puara/TouchArrayAvnd.cpp
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;
Copy link
Copy Markdown
Member

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& instead

Copy link
Copy Markdown
Contributor Author

@yrevash yrevash Jun 13, 2025

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)

The compiler threw an error: Cannot initialise a parameter of type 'int *' with an rvalue of type 'const value_type *' (aka 'const int *').

This is C++'s const-correctness preventing me from passing const data to a function that could potentially modify it (because it expects a non-const int*).

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.

Copy link
Copy Markdown
Contributor Author

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.h is 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);

Copy link
Copy Markdown
Member

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

const int touch_size = static_cast<int>(current_touch_array_data.size());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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;
}

}
68 changes: 68 additions & 0 deletions Puara/TouchArrayAvnd.hpp
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};
};

}