Skip to content

Commit

Permalink
Make a larger gesture recognizer object
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Oct 31, 2024
1 parent 096f474 commit 22af354
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 63 deletions.
110 changes: 58 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,75 @@ if(NOT TARGET score_plugin_avnd)
endif()

project(score_addon_puara LANGUAGES CXX)
avnd_score_plugin_init(
BASE_TARGET score_addon_puara
)

target_sources(score_addon_puara PRIVATE
3rdparty/puara-gestures/descriptors/IMU_Sensor_Fusion/imu_orientation.cpp
# 3rdparty/puara-gestures/descriptors/puara-utils.cpp
)

avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES
Puara/LeakyIntegrator.hpp
TARGET puara
MAIN_CLASS LeakyIntegrator
NAMESPACE Puara
)

avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES
Puara/Roll.hpp
Puara/Roll.cpp
TARGET puara_roll
MAIN_CLASS Roll
NAMESPACE puara_gestures::objects
)
set(PUARA_GESTURES_ENABLE_TESTING OFF)
add_subdirectory(3rdparty/puara-gestures SYSTEM)

avnd_score_plugin_add(
avnd_score_plugin_init(
BASE_TARGET score_addon_puara
SOURCES
Puara/Tilt.hpp
Puara/Tilt.cpp
TARGET puara_tilt
MAIN_CLASS Tilt
NAMESPACE puara_gestures::objects
)

avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES
Puara/Jab.hpp
Puara/Jab.cpp
TARGET puara_jab
MAIN_CLASS Jab
NAMESPACE puara_gestures::objects
)
target_link_libraries(score_addon_puara PRIVATE puara_gestures)

avnd_score_plugin_add(
BASE_TARGET score_addon_puara
SOURCES
Puara/Shake.hpp
Puara/Shake.cpp
TARGET puara_shake
MAIN_CLASS Shake
Puara/GestureRecognizer.hpp
Puara/GestureRecognizer.cpp
TARGET puara
MAIN_CLASS GestureRecognizer
NAMESPACE puara_gestures::objects
)

target_include_directories(score_addon_puara
PRIVATE
3rdparty/puara-gestures
3rdparty/puara-gestures/descriptors
)
#
#
# avnd_score_plugin_add(
# BASE_TARGET score_addon_puara
# SOURCES
# Puara/LeakyIntegrator.hpp
# TARGET puara
# MAIN_CLASS LeakyIntegrator
# NAMESPACE Puara
# )
#
# avnd_score_plugin_add(
# BASE_TARGET score_addon_puara
# SOURCES
# Puara/Roll.hpp
# Puara/Roll.cpp
# TARGET puara_roll
# MAIN_CLASS Roll
# NAMESPACE puara_gestures::objects
# )
#
# avnd_score_plugin_add(
# BASE_TARGET score_addon_puara
# SOURCES
# Puara/Tilt.hpp
# Puara/Tilt.cpp
# TARGET puara_tilt
# MAIN_CLASS Tilt
# NAMESPACE puara_gestures::objects
# )
#
# avnd_score_plugin_add(
# BASE_TARGET score_addon_puara
# SOURCES
# Puara/Jab.hpp
# Puara/Jab.cpp
# TARGET puara_jab
# MAIN_CLASS Jab
# NAMESPACE puara_gestures::objects
# )
#
# avnd_score_plugin_add(
# BASE_TARGET score_addon_puara
# SOURCES
# Puara/Shake.hpp
# Puara/Shake.cpp
# TARGET puara_shake
# MAIN_CLASS Shake
# NAMESPACE puara_gestures::objects
# )

avnd_score_plugin_finalize(
BASE_TARGET score_addon_puara
Expand Down
17 changes: 17 additions & 0 deletions Puara/GestureRecognizer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "GestureRecognizer.hpp"
namespace puara_gestures::objects
{
void GestureRecognizer::operator()(halp::tick t)
{
const double period = t.frames / setup.rate;

auto [ax, ay, az] = inputs.accel.value;
jab.update(ax, ay, az);
shake.update(ax, ay, az);

outputs.jab = jab.current_value();
outputs.shake = shake.current_value();
outputs.tilt = tilt.tilt(inputs.accel, inputs.gyro, inputs.mag, period);
outputs.roll = roll.roll(inputs.accel, inputs.gyro, inputs.mag, period);
}
}
44 changes: 44 additions & 0 deletions Puara/GestureRecognizer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>
#include <puara/gestures.h>

namespace puara_gestures::objects
{
class GestureRecognizer
{
public:
halp_meta(name, "Gesture recognizer")
halp_meta(category, "Gestures")
halp_meta(c_name, "puara_roll")
halp_meta(uuid, "3135b5e0-39a6-4151-8ae4-a657d577eab8")

struct ins
{
halp::val_port<"Acceleration", puara_gestures::Coord3D> accel;
halp::val_port<"Gyrosocope", puara_gestures::Coord3D> gyro;
halp::val_port<"Magnetometer", puara_gestures::Coord3D> mag;
} inputs;

struct
{
halp::val_port<"Jab", puara_gestures::Coord3D> jab;
halp::val_port<"Shake", puara_gestures::Coord3D> shake;
halp::val_port<"Tilt", float> tilt;
halp::val_port<"Roll", float> roll;
} outputs;

halp::setup setup;
void prepare(halp::setup info) { setup = info; }

using tick = halp::tick;
void operator()(halp::tick t);

puara_gestures::Jab3D jab;
puara_gestures::Shake3D shake;
puara_gestures::Tilt tilt;
puara_gestures::Roll roll;
};

}
3 changes: 1 addition & 2 deletions Puara/Jab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>

#include <puara-jab.h>
#include <puara/descriptors/jab.h>

namespace puara_gestures::objects
{
Expand Down
3 changes: 1 addition & 2 deletions Puara/LeakyIntegrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>

#include <descriptors/puara-utils.h>
#include <puara/utils/leakyintegrator.h>

namespace Puara
{
Expand Down
3 changes: 1 addition & 2 deletions Puara/Roll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>

#include <puara-roll.h>
#include <puara/descriptors/roll.h>

namespace puara_gestures::objects
{
Expand Down
3 changes: 1 addition & 2 deletions Puara/Shake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>

#include <puara-shake.h>
#include <puara/descriptors/shake.h>

namespace puara_gestures::objects
{
Expand Down
3 changes: 1 addition & 2 deletions Puara/Tilt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/meta.hpp>

#include <puara-tilt.h>
#include <puara/descriptors/tilt.h>

namespace puara_gestures::objects
{
Expand Down

0 comments on commit 22af354

Please sign in to comment.