diff options
-rwxr-xr-x | common.c | 26 | ||||
-rwxr-xr-x | common.h | 6 | ||||
-rwxr-xr-x | rhythms_memory.c | 13 | ||||
-rwxr-xr-x | test-rhythms_memory.pd | 15 |
4 files changed, 32 insertions, 28 deletions
@@ -387,7 +387,7 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, unsigned short int *src_rhythm_array, *tmp_rhythm_array;
unsigned short int best_subid, curr_subid;
float best_closeness, curr_closeness;
- int sub_ok, sub_no;
+ int sub_ok, sub_no, sub_count;
int count_strong;
t_rhythm_memory_element *possible_rhythms;
@@ -408,6 +408,7 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, strong_ok=0;
strong_no=0;
strong_ratio=0;
+ /*
average_weight = 0;
while(curr_event)
{
@@ -419,7 +420,15 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, beats++;
curr_event = curr_event->next;
}
-
+ // this is the average weight of this rhythm in this representation
+ if (beats==0)
+ {
+ average_weight = 0;
+ } else
+ {
+ average_weight = (float) (average_weight / ((float) beats));
+ }
+ */
// look all the representation's rhythm
// looking for strong beats corrispondance
count_strong = 0;
@@ -446,14 +455,6 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, }
}
- // this is the average weight of this rhythm in this representation
- if (beats==0)
- {
- average_weight = 0;
- } else
- {
- average_weight = (float) (average_weight / ((float) beats));
- }
// ratio of corresponding strong beats..
// close to 0 = no corrispondance
// close to 1 = corrispondance
@@ -476,7 +477,7 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, {
// create the table of this rhythm
create_array_beats(&tmp_rhythm_array, possible_rhythms->rhythm);
- sub_ok = sub_no = 0;
+ sub_ok = sub_no = sub_count = 0;
for (i=0; i<max_i; i++)
{
if (tmp_rhythm_array[i]>0 && src_rhythm_array[i]>0)
@@ -489,13 +490,14 @@ void compare_rhythm_vs_representation(t_rhythm_memory_representation *this_rep, {
sub_no++;
}
+ sub_count++;
}
if (sub_no == 0)
{
curr_closeness = 1;
} else
{
- curr_closeness = (float) ( ((float) sub_ok) / ((float) sub_no) );
+ curr_closeness = (float) (( ((float) sub_ok) - ((float) sub_no) ) / ((float) sub_count));
}
if (curr_closeness > best_closeness)
{
@@ -77,8 +77,10 @@ struct t_rhythm_memory_arc } ;
// it will be arranged in a heap list.. ?
-#define num_possible_denominators 11
-static unsigned short int possible_denominators[] = {1,2,3,4,6,8,12,16,18,24,32};
+//#define num_possible_denominators 11
+//static unsigned short int possible_denominators[] = {1,2,3,4,6,8,12,16,18,24,32};
+#define num_possible_denominators 7
+static unsigned short int possible_denominators[] = {1,2,3,4,6,8,12};
// the minimum percentage for a beat to be considered part of the main rhythm
#define min_to_be_main_rhythm_beat 0.7
diff --git a/rhythms_memory.c b/rhythms_memory.c index dd6871e..f750c19 100755 --- a/rhythms_memory.c +++ b/rhythms_memory.c @@ -2,16 +2,15 @@ rhythms_memory
by Davide Morelli www.davidemorelli.it 2005
-a working version of rhythms_memory
-
uses graphs to store rhythms
TODO:
- * test and debug core functionalities
- * memory save/load to file
- * output rhythms in the form of list of floats
- * add velo
- * input rhythms from a list (second inlet)
+ * memory save/load to file (?)
+ * output rhythms in the form of list of floats (easy)
+ * add velo (?)
+ * input rhythms from a list (second inlet) (easy)
+ * let it create variations on known rhythms (?)
+ * let it merge rhythms (?)
*/
diff --git a/test-rhythms_memory.pd b/test-rhythms_memory.pd index 67f9221..d2287e7 100755 --- a/test-rhythms_memory.pd +++ b/test-rhythms_memory.pd @@ -1,11 +1,11 @@ -#N canvas 91 38 909 527 12;
+#N canvas 91 38 913 531 12;
#X obj 126 256 rhythms_memory;
#X msg 126 212 measure;
#X msg 232 220 0;
#X obj 123 48 metro 500;
#X obj 85 86 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
-#X obj 123 25 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+#X obj 123 25 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
;
#X obj 124 71 int 0;
#X obj 175 72 + 1;
@@ -47,7 +47,6 @@ -1;
#X obj 270 187 dac~;
#X floatatom 180 155 5 0 0 0 - - -;
-#X msg 384 39 rhythm 1 1;
#X obj 126 294 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X msg 489 133 1 0 0.5;
@@ -61,8 +60,10 @@ of floats (TODO); #X text 235 315 here you'll get the wanted rhythms in the form of lists
of floats (TODO);
#X text 373 361 here you get info on the last detected rhythm;
-#X connect 0 0 26 0;
-#X connect 0 1 31 0;
+#X msg 384 39 rhythm_out 6 0;
+#X connect 0 0 25 0;
+#X connect 0 0 21 0;
+#X connect 0 1 30 0;
#X connect 0 2 12 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
@@ -89,5 +90,5 @@ of floats (TODO); #X connect 21 0 23 1;
#X connect 22 0 21 0;
#X connect 22 0 11 0;
-#X connect 25 0 0 0;
-#X connect 27 0 0 1;
+#X connect 26 0 0 1;
+#X connect 34 0 0 0;
|