Skip to content

Commit

Permalink
update of the PureData object, tested on MacOSX
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaramiaux committed Jan 30, 2016
1 parent e53672f commit b36689c
Show file tree
Hide file tree
Showing 7 changed files with 442 additions and 700 deletions.
7 changes: 7 additions & 0 deletions GVFlib/GVFGesture.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#ifndef GVFGesture_h
#define GVFGesture_h

#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif


class GVFGesture
Expand Down
Binary file modified maxmsp/max-patches/gvf.mxo/Contents/MacOS/gvf
Binary file not shown.
26 changes: 7 additions & 19 deletions maxmsp/xcode/gvf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,18 @@
//
///////////////////////////////////////////////////////////////////////





#include "ext.h" // standard Max include, always required
#include "ext_obex.h" // required for new style Max object
#include "ext.h"
#include "ext_obex.h"
#include "GVF.h"
#include "GVFGesture.h"
#include <iostream>
#include <sstream>
#include <fstream>



////////////////////////// object struct
typedef struct _gvf
{
t_object ob; // the object itself (must be first)

t_object ob;
// GVF related variables
GVF *bubi;
GVFGesture *currentGesture;
Expand Down Expand Up @@ -59,10 +52,10 @@ t_max_err getAttr(t_gvf *x, t_object *attr, long* ac, t_atom** av);
t_max_err setAttr(t_gvf *x, void *attr, long ac, t_atom *av);

//// BASICS
void gvf_record (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_record (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_start (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_stop (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_play (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_follow (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_clear (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_list (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_printme (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
Expand All @@ -89,17 +82,12 @@ void gvf_export (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_import (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);

//// DEPRECATED
void gvf_follow (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_gestureOn (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_gestureOff (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_adaptation_speed (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);
void gvf_play (t_gvf *x, const t_symbol *sss, short argc, t_atom *argv);



//////////////////////// global variables and co
void *gvf_class;
bool manuallyAssignedGesture = false;



int C74_EXPORT main(void)
Expand Down Expand Up @@ -315,7 +303,7 @@ void gvf_start(t_gvf *x,const t_symbol *sss, short argc, t_atom *argv)
// ---------------------------------------------------------------------------
void gvf_stop(t_gvf *x,const t_symbol *sss, short argc, t_atom *argv)
{
error("'stop' does nothing, only start can be used");
error("'stop' message does nothing, only start can be used");
}

// "follow" msg
Expand Down
Binary file not shown.
26 changes: 14 additions & 12 deletions puredata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ UNITTESTS =
#
#------------------------------------------------------------------------------#

ALL_CFLAGS = -I"$(PD_INCLUDE)" -I"../src"
ALL_CFLAGS = -I"$(PD_INCLUDE)" -I"../GVFlib"
ALL_LDFLAGS =
SHARED_LDFLAGS =
ALL_LIBS =
Expand Down Expand Up @@ -104,17 +104,18 @@ ifeq ($(UNAME),Darwin)
OPT_CFLAGS = -ftree-vectorize -fast
# build universal 32-bit on 10.4 and 32/64 on newer
ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4
FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.7
else
SOURCES += $(SOURCES_iphoneos)
# Starting with Xcode 4.0, the PowerPC compiler is not installed by default
ifeq ($(wildcard /usr/llvm-gcc-4.2/libexec/gcc/powerpc*), )
FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=10.5
FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=10.7
else
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.7
endif
endif
ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
SPEC_CPPFLAGS = -std=gnu++11 -stdlib=libc++
# if the 'pd' binary exists, check the linking against it to aid with stripping
BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
Expand Down Expand Up @@ -170,7 +171,9 @@ ifeq ($(UNAME),Linux)
OS = linux
PD_PATH = /usr
OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
ALL_CFLAGS += -fPIC
ALL_CFLAGS += -fPIC -I../GVFlib
SPEC_CFLAGS = -std=c99
SPEC_CPPFLAGS = -std=c++11
ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
ALL_LIBS += -lc $(LIBS_linux)
Expand Down Expand Up @@ -261,14 +264,14 @@ SHARED_TCL_LIB = $(wildcard lib$(LIBRARY_NAME).tcl)
all: gvf.$(EXTENSION) $(SHARED_LIB)

%.o: %.cpp
$(CC) $(ALL_CFLAGS) -o "$*.o" -c "$*.cpp"
$(CC) $(ALL_CFLAGS) $(SPEC_CPPFLAGS) -o "$*.o" -c "$*.cpp"

../src/ofxGVF.o: ../src/ofxGVF.cpp
$(CC) $(ALL_CFLAGS) -o "../src/ofxGVF.o" -c "../src/ofxGVF.cpp"
../GVFlib/GVF.o: ../GVFlib/GVF.cpp
$(CC) $(ALL_CFLAGS) $(SPEC_CPPFLAGS) -o "../GVFlib/GVF.o" -c "../GVFlib/GVF.cpp"

%.$(EXTENSION): %.o ../src/ofxGVF.o $(SHARED_LIB)
$(CC) $(ALL_LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" "../src/ofxGVF.o" $(ALL_LIBS) $(SHARED_LIB)
rm ../src/ofxGVF.o
%.$(EXTENSION): %.o ../GVFlib/GVF.o $(SHARED_LIB)
$(CC) $(ALL_LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" "../GVFlib/GVF.o" $(ALL_LIBS) $(SHARED_LIB)
rm ../GVFlib/GVF.o
rm -f -- $(SOURCES:.cpp=.o) $(SOURCES_LIB:.cpp=.o) $(SHARED_SOURCE:.c=.o)
mkdir -p Build/$(UNAME)/
mv gvf.$(EXTENSION) Build/$(UNAME)/
Expand Down Expand Up @@ -342,7 +345,6 @@ install-unittests:
done

clean:
-rm -f ../src/GestureVariationFollower.o
-rm -f -- $(SOURCES:.cpp=.o) $(SOURCES_LIB:.cpp=.o) $(SHARED_SOURCE:.c=.o)
-rm -f -- $(SOURCES:.cpp=.$(EXTENSION))
-rm -f -- $(LIBRARY_NAME).o
Expand Down
197 changes: 83 additions & 114 deletions puredata/gvf-help.pd
Original file line number Diff line number Diff line change
@@ -1,125 +1,94 @@
#N canvas 175 171 1215 593 10;
#N canvas 162 33 1062 608 10;
#X declare -lib gvf;
#X declare -lib mrpeach;
#X obj 390 311 import gvf;
#X obj 19 311 gvf this is the help patch ---------------------------------
#X obj 390 240 import gvf;
#X obj 19 240 gvf this is the help patch ---------------------------------
;
#X msg 19 10 learn;
#X text 1051 -2 <-- import mrpeach objects;
#X obj 949 -1 import mrpeach;
#X obj 951 79 unpackOSC;
#X obj 951 54 udpreceive 9003;
#X msg 19 223 clear;
#X obj 19 374 print Phase;
#X obj 376 374 print Likelihoods;
#X obj 286 374 print Rotation;
#X obj 197 374 print Scaling;
#X obj 108 374 print Speed;
#X msg 19 118 follow;
#X obj 935 149 s gvf;
#X obj 19 286 r gvf;
#X text 657 309 <-- import mrpeach objects;
#X obj 555 310 import mrpeach;
#X obj 554 350 unpackOSC;
#X obj 554 330 udpreceive 9003;
#X msg 553 -7 clear;
#X obj 304 373 print Likelihoods;
#X msg 53 95 follow;
#X obj 554 391 s gvf;
#X obj 19 215 r gvf;
#X obj 16 -111 cnv 15 552 40 empty \$0-pddp.cnv.header GVF 3 12 1 18
-262144 -191407 0;
#N canvas 214 166 507 398 README 0;
#X text 16 9 The current implementation of the Gesture Variation Follower
proposes:;
#X text 16 83 Adaptation of: phase \, speed \, scale \, rotation;
#X text 16 123 N-dimensional inputs (e.g. accelerometers \, biosignals
\, ...);
#X text 15 138 Adaptation of: phase \, speed \, scale;
#X text 14 198 You can choose to automatically translate the data according
to the first input point by sending "translate 1" otherwise "translate
0". Translation is highly recommended for 2-d shapes.;
#X msg 17 259 translate 0;
#X msg 100 260 translate 1;
#X text 16 68 2-dimensional and 3-dimensional inputs (e.g. shapes)
;
#X restore 233 -112 pd README;
#X text 18 -90 GVF - Gesture Variation Follower;
#X text 18 -79 realtime gesture recognition with variations estimation
;
#X text 1054 54 <-- listen to port 9003;
#X text 657 330 <-- listen to port 9003;
#X text 19 -62 (c) Ircam Centre Pompidou \, Goldsmiths University of
London version: 06-2014 sources: https://github.com/bcaramiaux/gvf
;
#X msg 19 32 start;
#X msg 19 53 stop;
#X obj 1009 147 print;
#X obj 951 109 route /osc/data;
#X msg 19 146 restart;
#X text 119 116 <-- send the message follow and send gesture data;
#X text 119 143 <-- Important: at the beginning of each gesture \,
send "restart";
#X text 120 19 <-- send the message learn;
#X text 28 -16 LEARNING;
#X text 28 93 PERFORMING;
#X text 29 186 CLEAR;
#X text 120 220 <-- clear all the templates in GVF;
#X msg 529 -33 printme;
#X obj 492 -33 s gvf;
#X msg 529 68 tolerance \$1;
#X floatatom 529 47 10 0 0 0 - - -;
#X text 595 46 Tolerance (choose between 0.01 and ...);
#X msg 529 -13 translate 1;
#X msg 529 7 segmentation 0;
#X floatatom 529 132 10 0 100000 0 - - -;
#X text 595 131 Number of Particles (it's an integer!);
#X obj 492 -13 s gvf;
#X floatatom 529 229 10 0 0 0 - - -;
#X floatatom 528 270 10 0 0 0 - - -;
#X floatatom 528 312 10 0 0 0 - - -;
#X floatatom 528 353 10 0 0 0 - - -;
#X text 595 228 phase adaptation (between 1e-10 and 0.1);
#X text 594 352 rotation adaptation (between 1e-10 and 0.1);
#X text 594 311 scale adaptation (between 1e-10 and 0.1);
#X text 594 269 speed adaptation (between 1e-10 and 0.1);
#X obj 492 8 s gvf;
#X obj 492 68 s gvf;
#X obj 492 153 s gvf;
#X obj 492 249 s gvf;
#X obj 489 291 s gvf;
#X obj 491 334 s gvf;
#X obj 490 373 s gvf;
#X text 516 109 ADVANCED;
#X msg 529 153 numberparticles \$1;
#X msg 529 250 phaseadaptation \$1;
#X msg 528 291 speedadaptation \$1;
#X msg 528 333 scaleadaptation \$1;
#X msg 528 374 rotationadaptation \$1;
#X floatatom 530 174 10 0 100000 0 - - -;
#X obj 493 195 s gvf;
#X text 596 173 Resampling threshold (it's an integer!);
#X msg 530 195 resamplingthreshold \$1;
#X connect 1 0 8 0;
#X connect 1 1 12 0;
#X connect 1 2 11 0;
#X connect 1 3 10 0;
#X connect 1 4 9 0;
#X connect 2 0 1 0;
#X connect 5 0 25 0;
#X connect 6 0 5 0;
#X connect 7 0 1 0;
#X connect 13 0 1 0;
#X connect 15 0 1 0;
#X connect 22 0 1 0;
#X connect 23 0 1 0;
#X connect 25 0 14 0;
#X connect 25 0 24 0;
#X connect 26 0 1 0;
#X connect 34 0 35 0;
#X connect 36 0 53 0;
#X connect 37 0 36 0;
#X connect 39 0 43 0;
#X connect 40 0 52 0;
#X connect 41 0 60 0;
#X connect 44 0 61 0;
#X connect 45 0 62 0;
#X connect 46 0 63 0;
#X connect 47 0 64 0;
#X connect 60 0 54 0;
#X connect 61 0 55 0;
#X connect 62 0 56 0;
#X connect 63 0 57 0;
#X connect 64 0 58 0;
#X connect 65 0 68 0;
#X connect 68 0 66 0;
#X msg 29 32 start;
#X obj 554 370 route /osc/data;
#X text 111 93 <-- send the message follow and send gesture data;
#X text 16 -8 LEARNING;
#X text 50 74 PERFORMING;
#X msg 553 117 tolerance \$1;
#X floatatom 645 117 10 0 0 0 - - -;
#X msg 553 39 translate 1;
#X msg 553 61 segmentation 0;
#X floatatom 645 147 10 0 100000 0 - - -;
#X text 718 147 Number of Particles (it's an integer!);
#X floatatom 645 176 10 0 0 0 - - -;
#X floatatom 644 206 10 0 0 0 - - -;
#X floatatom 644 236 10 0 0 0 - - -;
#X obj 553 85 s gvf;
#X obj 553 261 s gvf;
#X msg 19 10 record;
#X msg 553 16 printme;
#X obj 19 374 print Alignment;
#X obj 90 343 print Dynamics;
#X obj 161 374 print Scalings;
#X obj 233 344 print Rotations;
#X text 87 32 <-- send start to start a gesture then send the data
;
#X text 87 11 <-- send the message record for each new gesture;
#X msg 61 119 start;
#X text 111 118 <-- send start to start a gesture then send the data
;
#X text 658 37 Translate gesture feature data according to the first
point;
#X text 658 60 Segment automatically (no need to press start at each
new gesture in foloowing mode);
#X text 716 117 Tolerance;
#X msg 553 147 particles \$1;
#X msg 553 176 dynamics \$1;
#X text 718 177 Adaptation of dynamics (speed and acceleration);
#X text 717 207 Adaptation of scalings;
#X text 717 235 Adaptation of rotations;
#X msg 553 236 rotations \$1;
#X msg 553 206 scalings \$1;
#X text 658 11 Print internal data of GVF;
#X text 658 -11 Clear GVF (templates and training);
#X text 554 284 Data stream used to test GVF;
#X connect 1 0 34 0;
#X connect 1 1 35 0;
#X connect 1 2 36 0;
#X connect 1 3 37 0;
#X connect 1 4 7 0;
#X connect 4 0 17 0;
#X connect 5 0 4 0;
#X connect 6 0 30 0;
#X connect 8 0 1 0;
#X connect 10 0 1 0;
#X connect 16 0 1 0;
#X connect 17 0 9 0;
#X connect 21 0 31 0;
#X connect 22 0 21 0;
#X connect 23 0 30 0;
#X connect 24 0 30 0;
#X connect 25 0 45 0;
#X connect 27 0 46 0;
#X connect 28 0 51 0;
#X connect 29 0 50 0;
#X connect 32 0 1 0;
#X connect 33 0 30 0;
#X connect 40 0 1 0;
#X connect 46 0 31 0;
#X connect 50 0 31 0;
#X connect 51 0 31 0;
#X coords 0 593 1 592 85 60 0;
Loading

0 comments on commit b36689c

Please sign in to comment.