aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGArhythm.c5
-rwxr-xr-xchords_memory.c9
-rwxr-xr-xcommon.h22
3 files changed, 12 insertions, 24 deletions
diff --git a/GArhythm.c b/GArhythm.c
index 9de31ff..a055026 100755
--- a/GArhythm.c
+++ b/GArhythm.c
@@ -2,6 +2,7 @@
*/
#include <stdlib.h>
+#include <time.h>
#include "m_pd.h"
#define BUFFER_LENGHT 16 // lunghezza dei buffers (quanti elementi nel pattern)
@@ -49,6 +50,7 @@ void GArhythm_init_pop(t_GArhythm *x)
{
int i, j, tmp, k;
double rnd;
+
for (i=0; i<MAX_POPULATION; i++)
{
for (j=0; j<BUFFER_LENGHT; j++)
@@ -649,7 +651,8 @@ static void *GArhythm_new(t_symbol *s, int argc, t_atom *argv)
x->reinsert_src=REINSERT_SRC;
x->reinsert_last=REINSERT_LAST;
-
+ srand( (unsigned)time( NULL ) );
+
if (argc>0)
{
x->x_arrayname_src_strum1 = atom_getsymbolarg(0, argc, argv);
diff --git a/chords_memory.c b/chords_memory.c
index 0c3d53a..e9e95ae 100755
--- a/chords_memory.c
+++ b/chords_memory.c
@@ -132,6 +132,7 @@ typedef struct _chords_memory
t_outlet *x_outchordname; /* chord name, e.g. "Cmajor7" */
t_outlet *x_outtonalityname; /* chord name, e.g. "Cmajor7" */
t_outlet *x_outchordssequence; /* sequence of chords,a walk */
+ t_outlet *x_outnovelty; /* the degree of novelty of last added chord */
// the matrix : arcs of the graph
// each tonality mode has his matrix
// each matrix is in this form:
@@ -772,7 +773,7 @@ void chords_memory_set_chord(t_chords_memory *x, t_symbol *s) {
}
// add a chord sequence to the graph
-void chords_memory_add(t_chords_memory *x, chord_t chord1, chord_t chord2)
+float chords_memory_add(t_chords_memory *x, chord_t chord1, chord_t chord2)
{
// chords are integers
// to know what this integer means do that:
@@ -794,6 +795,7 @@ void chords_memory_add(t_chords_memory *x, chord_t chord1, chord_t chord2)
if (DEBUG)
post("x->maxweight[%i] = %i",x->fundamental_mode, x->maxweight[x->fundamental_mode]);
}
+ return (float) (((float) x->maxweight[x->fundamental_mode]) / ((float) x->arcs[x->fundamental_mode][chord1int][chord2int]) );
}
@@ -801,10 +803,11 @@ void chords_memory_add(t_chords_memory *x, chord_t chord1, chord_t chord2)
// the external remembers the previous played chord
void chords_memory_add_chord(t_chords_memory *x, t_symbol *s) {
chord_t chord1;
+ float ret = 0;
chord1 = chords_memory_string2chord(x, s->s_name);
if (x->last_chord_set)
{
- chords_memory_add(x, x->last_chord, chord1);
+ ret = chords_memory_add(x, x->last_chord, chord1);
}
else
{
@@ -813,6 +816,7 @@ void chords_memory_add_chord(t_chords_memory *x, t_symbol *s) {
x->last_chord = chord1;
if (DEBUG)
post("chord added: %s", s->s_name);
+ outlet_float(x->x_outnovelty, ret);
}
// sets the current tonality
@@ -996,6 +1000,7 @@ void *chords_memory_new(t_symbol *s, int argc, t_atom *argv)
x->x_outchordname = outlet_new(&x->x_obj, gensym("symbol"));
x->x_outtonalityname = outlet_new(&x->x_obj, gensym("symbol"));
x->x_outchordssequence = outlet_new(&x->x_obj, gensym("list"));
+ x->x_outnovelty = outlet_new(&x->x_obj, gensym("float"));
srand(time(&a));
chords_memory_init_graph(x);
x->fundamental_note = C;
diff --git a/common.h b/common.h
index 90d0190..53baa34 100755
--- a/common.h
+++ b/common.h
@@ -133,27 +133,7 @@ struct t_rhythm_memory_representation
// tells you how many durations there // how can a chord be?
#define TYPES_NUM 69 // keep me updated
typedef enum {
- /*
- kMaj=0,
- kMin=1,
- kDim=2,
- kAug=3,
- kDom7=4,
- kMaj7=5,
- kMin7=6,
- kMinMaj7=7,
- kDim7=8,
- kHalfDim7=9,
- //pland adding 9ths 30.11.05 and beyond
- kDomb9=10,
- kMaj9=11,
- kDom9=12,
- kMin9=13,
- kHalfDim9=14,
- kMinMaj9=15,
- kDimMaj9=16
-*/
- // this enumerators are from maxlib chord
+ // this enumerator is from maxlib chord
kUnison = 0,
kMaj = 1,
kMin = 2,