aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Morelli <morellid@users.sourceforge.net>2005-12-22 23:21:04 +0000
committerDavide Morelli <morellid@users.sourceforge.net>2005-12-22 23:21:04 +0000
commitf428146b3bf8d4b3073b4fa826c250743f20fe7f (patch)
treec016025a2289e61a90427f1a4cc1c00cc2911971
parent6b999630484e02b53c0bc71d0bcc5da1919728c8 (diff)
fixed a bug in duration2int, now rhythms_memory working
svn path=/trunk/externals/frankenstein/; revision=4286
-rwxr-xr-xcommon.c6
-rwxr-xr-xrhythms_memory.c12
-rwxr-xr-xtest-rhythms_memory.pd71
3 files changed, 67 insertions, 22 deletions
diff --git a/common.c b/common.c
index c98b92b..9fe2c36 100755
--- a/common.c
+++ b/common.c
@@ -46,7 +46,7 @@ unsigned short int duration2int(t_duration dur)
{
for (j=0; j<i; j++)
{
- if ((dur.numerator==j) && (dur.denominator==i))
+ if ((dur.numerator==j) && (dur.denominator==possible_denominators[i]))
{
return curr;
} else
@@ -612,14 +612,14 @@ void rhythm_memory_evaluate(t_rhythm_memory_representation *rep_list, // the mem
// decide if add to the memory or if return the closest
- if (root_closeness_found>=min_to_be_same_rhythm)
+ if (root_closeness_found >= (float)min_to_be_same_rhythm)
{
// is close enough to be considered a rhythm
post("DEBUG: rhythm found");
*new_rhythm = 0;
*id = id_found;
*root_closeness = root_closeness_found;
- if (sub_closeness_found>=min_to_be_same_subrhythm)
+ if (sub_closeness_found >= (float)min_to_be_same_subrhythm)
{
// this is a known subrhythm
post("DEBUG: sub-rhythm found");
diff --git a/rhythms_memory.c b/rhythms_memory.c
index b885a05..8630336 100755
--- a/rhythms_memory.c
+++ b/rhythms_memory.c
@@ -195,6 +195,14 @@ void *rhythms_memory_new(t_symbol *s, int argc, t_atom *argv)
return (x);
}
+// debugging function
+void crash(t_rhythms_memory *x)
+{
+ int *a;
+ a = malloc(sizeof(int));
+ a[9999999999999999999] = 1;
+}
+
void rhythms_memory_setup(void)
{
rhythms_memory_class = class_new(gensym("rhythms_memory"), (t_newmethod)rhythms_memory_new,
@@ -203,4 +211,8 @@ void rhythms_memory_setup(void)
class_addmethod(rhythms_memory_class, (t_method)end_measure, gensym("measure"), 0);
class_doaddfloat(rhythms_memory_class, (t_method)add_event);
+ class_addmethod(rhythms_memory_class, (t_method)crash, gensym("crash"), 0);
+
}
+
+
diff --git a/test-rhythms_memory.pd b/test-rhythms_memory.pd
index 753e8e9..4223f0f 100755
--- a/test-rhythms_memory.pd
+++ b/test-rhythms_memory.pd
@@ -1,16 +1,15 @@
-#N canvas 0 0 641 458 12;
+#N canvas 224 39 661 478 12;
#X obj 134 262 rhythms_memory;
#X msg 126 212 measure;
#X msg 317 224 0;
-#X obj 168 69 metro 500;
-#X obj 130 107 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+#X obj 168 46 metro 500;
+#X obj 130 84 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
-#X obj 168 46 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+#X obj 168 23 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
;
-#X obj 169 92 int 0;
-#X obj 220 93 + 1;
-#X obj 169 115 % 4;
-#X floatatom 196 152 5 0 0 0 - - -;
+#X obj 169 69 int 0;
+#X obj 220 70 + 1;
+#X obj 169 92 % 4;
#X obj 127 155 sel 0;
#X obj 125 185 bang;
#X obj 317 189 bng 30 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
@@ -21,7 +20,34 @@
#X floatatom 193 348 5 0 0 1 subid - -;
#X floatatom 225 368 5 0 0 1 root_closeness - -;
#X floatatom 257 391 5 0 0 1 sub_closeness - -;
-#X connect 0 0 13 0;
+#X text 344 314 (0=known \, 1=new root \, 2=new sub);
+#X obj 169 115 t f f;
+#X msg 444 194 crash;
+#N canvas 0 0 454 304 drum 0;
+#X obj 108 27 inlet;
+#X obj 108 212 outlet~;
+#X obj 139 93 noise~;
+#X obj 122 159 *~;
+#X obj 207 155 line;
+#X msg 224 101 1 10;
+#X obj 311 89 delay 50;
+#X msg 314 112 0 100;
+#X obj 245 56 t b b;
+#X connect 0 0 8 0;
+#X connect 2 0 3 0;
+#X connect 3 0 1 0;
+#X connect 4 0 3 1;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 4 0;
+#X connect 8 0 6 0;
+#X connect 8 1 5 0;
+#X restore 429 115 pd drum;
+#X obj 429 82 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 423 147 dac~;
+#X floatatom 192 152 5 0 0 0 - - -;
+#X connect 0 0 12 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 4 0;
@@ -30,13 +56,20 @@
#X connect 6 0 7 0;
#X connect 6 0 8 0;
#X connect 7 0 6 1;
-#X connect 8 0 9 0;
-#X connect 8 0 10 0;
-#X connect 10 0 11 0;
-#X connect 11 0 1 0;
-#X connect 12 0 2 0;
-#X connect 13 0 14 0;
-#X connect 13 1 15 0;
-#X connect 13 2 16 0;
-#X connect 13 3 17 0;
-#X connect 13 4 18 0;
+#X connect 8 0 19 0;
+#X connect 9 0 10 0;
+#X connect 10 0 1 0;
+#X connect 11 0 2 0;
+#X connect 12 0 13 0;
+#X connect 12 1 14 0;
+#X connect 12 2 15 0;
+#X connect 12 3 16 0;
+#X connect 12 4 17 0;
+#X connect 19 0 21 0;
+#X connect 19 0 24 0;
+#X connect 19 1 9 0;
+#X connect 20 0 0 0;
+#X connect 21 0 23 0;
+#X connect 21 0 23 1;
+#X connect 22 0 21 0;
+#X connect 22 0 11 0;