From ac33aae33bcd8e334755dfa6a725ffbb51a84931 Mon Sep 17 00:00:00 2001 From: Davide Morelli Date: Thu, 8 Dec 2005 16:31:11 +0000 Subject: fixing things svn path=/trunk/externals/frankenstein/; revision=4171 --- harmonizer.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'harmonizer.c') diff --git a/harmonizer.c b/harmonizer.c index 7277723..a270df9 100755 --- a/harmonizer.c +++ b/harmonizer.c @@ -263,7 +263,7 @@ void harmonizer_init_pop(t_harmonizer *x) { // i go up rnd = rand()/((double)RAND_MAX + 1); - steps = rnd * 5; // how many step (good notes) will I ignore? + steps = rnd * 5; // how many steps (good notes) will I ignore? note = insertpoint + steps; if (note >= POSSIBLE_NOTES) note = POSSIBLE_NOTES-1; @@ -272,7 +272,7 @@ void harmonizer_init_pop(t_harmonizer *x) { // i go down rnd = rand()/((double)RAND_MAX + 1); - steps = rnd * 5; // how many step (good notes) will I ignore? + steps = rnd * 5; // how many steps (good notes) will I ignore? note = insertpoint - steps; if (note < 0) note = 0; @@ -295,6 +295,8 @@ void harmonizer_free(t_harmonizer *x) int fitness(t_harmonizer *x, int *candidate) { int i, j, tmp, res, last, avgHI, avgLOW; + short int chord_notes[4]; + short int chord_notes_ok[4]; short int transitions[VOICES]; short int directions[VOICES]; // intervals between voices @@ -434,6 +436,41 @@ int fitness(t_harmonizer *x, int *candidate) // TODO: too many near limits? // TODO: is a complete chord? + // does this voicing have all 5 notes? + // first build a table for comparision + for (i=0; i<4; i++) + { + chord_notes[i] = (x->target_notes[i]) % 12; + chord_notes_ok[i] = 0; + } + for (i=0; i