aboutsummaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorDavide Morelli <morellid@users.sourceforge.net>2005-12-07 18:38:20 +0000
committerDavide Morelli <morellid@users.sourceforge.net>2005-12-07 18:38:20 +0000
commitefbd3f26e01a09b902357b0b103ac7abc94e483c (patch)
tree57bd9a03e3ff8c4a9a61de1be10dddc5671fef3e /common.c
parentb9406125392107f1fb6a548236e6bbdad3721bcf (diff)
still buggy.. the rhythms..
svn path=/trunk/externals/frankenstein/; revision=4164
Diffstat (limited to 'common.c')
-rwxr-xr-xcommon.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/common.c b/common.c
index f48a370..6656615 100755
--- a/common.c
+++ b/common.c
@@ -53,7 +53,7 @@ unsigned short int duration2int(t_duration dur)
curr++;
}
}
- return curr+1;
+ return curr;
}
int possible_durations()
@@ -148,18 +148,21 @@ void freeBeats(t_rhythm_event *currentEvent)
t_rhythm_event *prev;
t_rhythm_event *next;
+ if (currentEvent==0)
+ return;
+
// go to the first element of the list
while(currentEvent->previous)
currentEvent = currentEvent->previous;
// now free each element
next=currentEvent->next;
- do
+ while(currentEvent)
{
prev = currentEvent;
- next = currentEvent->next;
- free(currentEvent);
- } while(next);
+ currentEvent = currentEvent->next;
+ free(prev);
+ }
}
@@ -219,6 +222,8 @@ unsigned short int add_t_rhythm_memory_element(t_rhythm_memory_representation *t
t_rhythm_memory_arc *currArc, *newArc, *prevArc;
unsigned short int last, sub_id;
int i, arcFound;
+ if (new_rhythm==0)
+ return INVALID_RHYTHM;
// creates a new element of the list of similar rhythms
newElement = (t_rhythm_memory_element *) malloc(sizeof(t_rhythm_memory_element));
newElement->rhythm = new_rhythm;
@@ -341,7 +346,7 @@ void free_memory_representations(t_rhythm_memory_representation *this_rep)
void create_array_beats(unsigned short int **this_array, t_rhythm_event *currentEvent)
{
unsigned short int *new_array;
- t_rhythm_event *curr_event;
+ //t_rhythm_event *curr_event;
int i, maxi, startint;
maxi = possible_durations();
// allocate space for the nodes
@@ -352,12 +357,12 @@ void create_array_beats(unsigned short int **this_array, t_rhythm_event *current
new_array[i] = 0;
}
// set the actual data
- curr_event = currentEvent;
- while(curr_event)
+ //curr_event = currentEvent;
+ while(currentEvent)
{
- startint = duration2int(curr_event->start);
+ startint = duration2int(currentEvent->start);
new_array[startint]=1;
- curr_event = curr_event->next;
+ currentEvent = currentEvent->next;
}
*this_array = new_array;
@@ -635,6 +640,7 @@ void rhythm_memory_evaluate(t_rhythm_memory_representation *rep_list, // the mem
*sub_id = sub_id_found;
*sub_closeness = sub_closeness_found;
*new_rhythm = 2;
+ post("DEBUG: new subrhythm");
}
} else
{
@@ -662,6 +668,7 @@ void rhythm_memory_evaluate(t_rhythm_memory_representation *rep_list, // the mem
*id = new_id;
*root_closeness = 1;
*new_rhythm = 1;
+ post("DEBUG: new rhythm");
}
}