aboutsummaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test.c')
-rwxr-xr-xtest.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/test.c b/test.c
new file mode 100755
index 0000000..691d7a8
--- /dev/null
+++ b/test.c
@@ -0,0 +1,81 @@
+/*
+just a dummy test patch
+
+*/
+
+#include "m_pd.h"
+
+#include "common.h"
+#include <time.h>
+#include <math.h>
+#include <stdlib.h>
+
+static t_class *test_class;
+
+
+
+typedef struct _test
+{
+ t_object x_obj; // myself
+ t_outlet *l_out;
+ t_rhythm_event *seq;
+ int seq_initialized;
+
+} t_test;
+
+void test_free(t_test *x)
+{
+ freeBeats(x->seq);
+}
+
+static void test_bang(t_test *x) {
+
+ // generate a random value
+ float rnd;
+ t_rhythm_event *events;
+ t_duration dur;
+
+ rnd = rand()/((double)RAND_MAX + 1);
+ dur = float2duration(rnd);
+
+ post("random value=%f duration.numerator=%i duration.denominator=%i", rnd, dur.numerator, dur.denominator);
+
+ if (x->seq_initialized)
+ {
+ concatenateBeat(x->seq, 0, rnd);
+ } else
+ {
+ setFirstBeat(&(x->seq), 0, rnd);
+ x->seq_initialized = 1;
+ }
+
+ // print the sequence
+ events = x->seq;
+ while(events)
+ {
+ post("event: numerator=%i, denominator=%i", events->duration.numerator, events->duration.denominator);
+ events=events->next;
+ }
+
+}
+
+void *test_new(t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ time_t a;
+ t_test *x = (t_test *)pd_new(test_class);
+ x->l_out = outlet_new(&x->x_obj, &s_list);
+
+ x->seq_initialized = 0;
+
+ return (x);
+}
+
+void test_setup(void)
+{
+ test_class = class_new(gensym("test"), (t_newmethod)test_new,
+ (t_method)test_free, sizeof(t_test), CLASS_DEFAULT, A_GIMME, 0);
+ class_addbang(test_class, (t_method)test_bang);
+
+
+}