aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMakefile4
-rwxr-xr-xcommon.c58
-rwxr-xr-xcommon.h3
3 files changed, 52 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 86a00d2..5e1a37a 100755
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
# customize here !
#VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
VC="C:\Programmi\Microsoft Visual Studio .NET\Vc7"
-#PDPATH="H:\PureData\pd-0.38-3.msw\pd"
-PDPATH="C:\Documents and Settings\Davide\Documenti\personali\pd-0.38-3.msw\pd"
+PDPATH="H:\PureData\pd-0.38-3.msw\pd"
+#PDPATH="C:\Documents and Settings\Davide\Documenti\personali\pd-0.38-3.msw\pd"
current: pd_nt distclean
diff --git a/common.c b/common.c
index a42c717..9bd1211 100755
--- a/common.c
+++ b/common.c
@@ -214,14 +214,13 @@ void add_t_rhythm_memory_element(t_rhythm_memory_representation *this_rep, t_rhy
{
this_rep->similar_rhythms = newElement;
}
-
-
+ // now update the transition table..
}
// from (duration) to (start) style
void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
{
- t_rhythm_event *oldCurr, *newElement, *oldPrev;
+ t_rhythm_event *oldCurr, *newElement, *oldPrev, *newPrev;
float diff, currMoment;
t_duration dur_tmp;
@@ -229,6 +228,7 @@ void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
oldCurr = oldStyle;
oldPrev = 0;
currMoment = 0;
+ newPrev = 0;
// look for the first beat played in old rhythm
while (oldCurr && (! (oldCurr->played)))
@@ -251,9 +251,8 @@ void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
dur_tmp = float2duration(currMoment);
newElement->duration.numerator = dur_tmp.numerator;
newElement->duration.denominator = dur_tmp.denominator;
- newElement->previous = oldPrev;
- if (oldPrev)
- oldPrev->next = newElement;
+ newElement->previous = newPrev;
+ newPrev = newElement;
while (oldCurr)
{
@@ -265,9 +264,10 @@ void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
dur_tmp = float2duration(currMoment);
newElement->duration.numerator = dur_tmp.numerator;
newElement->duration.denominator = dur_tmp.denominator;
- newElement->previous = oldPrev;
- if (oldPrev)
- oldPrev->next = newElement;
+ newElement->previous = newPrev;
+ if (newPrev)
+ newPrev->next = newElement;
+ newPrev = newElement;
}
// prepare for the next event
dur_tmp.numerator = oldCurr->duration.numerator;
@@ -276,8 +276,6 @@ void swap_rhythm_to_start(t_rhythm_event *oldStyle, t_rhythm_event **newStyle)
oldPrev = oldCurr;
oldCurr = oldCurr->next;
}
-
-
}
// from (start) to (duration) style
@@ -286,6 +284,44 @@ void swap_rhythm_to_duration(t_rhythm_event *oldStyle, t_rhythm_event **newStyle
}
+void free_memory_representation(t_rhythm_memory_representation *this_rep)
+{
+ int i, maxi;
+ t_rhythm_memory_element *currElement, *tmpElement;
+ t_rhythm_memory_arc *currArc, *tmpArc;
+ // free the main rhythm
+ if (this_rep->main_rhythm)
+ {
+ freeBeats(this_rep->main_rhythm->rhythm);
+ free(this_rep->main_rhythm);
+ }
+
+ // free the table
+ maxi = possible_durations();
+ for (i=0; i<maxi; i++)
+ {
+ currArc = this_rep->transitions[i].arcs;
+ while (currArc)
+ {
+ tmpArc = currArc;
+ currArc = currArc->next_arc;
+ free(tmpArc);
+ }
+ }
+ free(this_rep->transitions);
+
+ // free the list of similar rhythms
+ currElement = this_rep->similar_rhythms;
+ while (currElement)
+ {
+ freeBeats(currElement->rhythm);
+ tmpElement = currElement;
+ currElement = currElement->next;
+ free(tmpElement);
+ }
+
+
+}
// ------------------- themes manipulation functions
diff --git a/common.h b/common.h
index e447f1d..02ac024 100755
--- a/common.h
+++ b/common.h
@@ -150,6 +150,9 @@ void init_rhythm_memory_representation(t_rhythm_memory_representation *this_rep)
// add a new rhythm in the list of similar rhythms related to one main rhythm
void add_similar_rhythm(t_rhythm_memory_representation *this_rep, t_rhythm_event *new_rhythm);
+// free the array with pointers and lists
+void free_memory_representation(t_rhythm_memory_representation *this_rep);
+
// functions needed to fill and use the memory table