aboutsummaryrefslogtreecommitdiff
path: root/old
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 21:39:24 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 21:39:24 +0000
commite420e83534daf42568eba431d3b994ef585dabf9 (patch)
treea4121117a9b87b0fd7807e04acbbef0629675f3a /old
parentb95a41d4163666368971d39c2a8d9af64501d36c (diff)
Added a place to store my old externals
svn path=/trunk/externals/tof/; revision=12494
Diffstat (limited to 'old')
-rw-r--r--old/wrapper-help.pd27
-rw-r--r--old/wrapper.c81
2 files changed, 108 insertions, 0 deletions
diff --git a/old/wrapper-help.pd b/old/wrapper-help.pd
new file mode 100644
index 0000000..06abf4d
--- /dev/null
+++ b/old/wrapper-help.pd
@@ -0,0 +1,27 @@
+#N canvas 226 243 486 349 10;
+#X text 114 176 Wraps between 0 and 1 by default;
+#X text 137 276 This instance wraps the input between 2 and 8;
+#X floatatom 52 205 5 0 0 0 - - -;
+#X floatatom 50 138 5 0 0 0 - - -;
+#X floatatom 91 138 5 0 0 0 - - -;
+#X floatatom 134 140 5 0 0 0 - - -;
+#X floatatom 50 242 5 0 0 0 - - -;
+#X floatatom 92 243 5 0 0 0 - - -;
+#X floatatom 136 242 5 0 0 0 - - -;
+#X floatatom 50 306 5 0 0 0 - - -;
+#X obj 52 177 wrapper;
+#X obj 50 277 wrapper 2 8;
+#X obj 42 2 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577
+0;
+#X text 47 36 author: mrtoftrash@gmail.com;
+#X text 48 2 description: wraps a number around a range;
+#X text 47 47 version: 2009-06-07 (initial release);
+#X text 47 25 tags: math range tof;
+#X connect 3 0 10 0;
+#X connect 4 0 10 1;
+#X connect 5 0 10 2;
+#X connect 6 0 11 0;
+#X connect 7 0 11 1;
+#X connect 8 0 11 2;
+#X connect 10 0 2 0;
+#X connect 11 0 9 0;
diff --git a/old/wrapper.c b/old/wrapper.c
new file mode 100644
index 0000000..8d0ec5e
--- /dev/null
+++ b/old/wrapper.c
@@ -0,0 +1,81 @@
+#include "m_pd.h"
+#include <math.h>
+
+static t_class *wrapper_class;
+
+typedef struct _wrapper {
+ t_object x_obj;
+
+ t_float min;
+ t_float max;
+ //t_int iterating;
+ t_outlet* outlet1;
+ //t_outlet* outlet2;
+} t_wrapper;
+
+/*
+void wrapper_bang(t_wrapper *x)
+{
+ //x->i_count = x->i_down;
+ x->iterating = 0;
+
+}
+*/
+
+void wrapper_float(t_wrapper *x, t_float f)
+{
+
+ t_float value = fmod(f - x->min ,x->max - x->min);
+ if ( value < 0 ) value = value + x->max;
+ else value = value + x->min;
+
+ outlet_float(x->outlet1, value);
+
+
+}
+
+
+
+static void wrapper_free(t_wrapper *x)
+{
+
+
+}
+
+void *wrapper_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_wrapper *x = (t_wrapper *)pd_new(wrapper_class);
+
+
+ if ( argc >= 2) {
+ x->min = atom_getfloat(argv);
+ x->max = atom_getfloat(argv+1);
+ } else if ( argc == 1) {
+ x->min = 0;
+ x->max = atom_getfloat(argv);
+ } else {
+ x->min = 0;
+ x->max = 1;
+ }
+
+ floatinlet_new(&x->x_obj, &x->min);
+ floatinlet_new(&x->x_obj, &x->max);
+ x->outlet1 = outlet_new(&x->x_obj, &s_float);
+
+
+
+ return (void *)x;
+}
+
+void wrapper_setup(void) {
+ wrapper_class = class_new(gensym("wrapper"),
+ (t_newmethod)wrapper_new,
+ (t_method)wrapper_free, sizeof(t_wrapper),
+ CLASS_DEFAULT,
+ A_GIMME, 0);
+
+ //class_addbang (wrapper_class, wrapper_bang);
+ class_addfloat (wrapper_class, wrapper_float);
+ //class_addlist (wrapper_class, wrapper_list);
+
+}