aboutsummaryrefslogtreecommitdiff
path: root/harmonizer.c
diff options
context:
space:
mode:
authorDavide Morelli <morellid@users.sourceforge.net>2006-01-16 00:56:01 +0000
committerDavide Morelli <morellid@users.sourceforge.net>2006-01-16 00:56:01 +0000
commit10a3fd828512907e52f3eabdd7c69b3eaa98757f (patch)
treee65efa6c521f79687cb25fab8bf0559b10759826 /harmonizer.c
parentd1ceaf286dcdd8b1ab51838d66a9df2b8ca4dce1 (diff)
fixed bugs in evaluating indices
svn path=/trunk/externals/frankenstein/; revision=4410
Diffstat (limited to 'harmonizer.c')
-rwxr-xr-xharmonizer.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/harmonizer.c b/harmonizer.c
index 9a99559..fc588f7 100755
--- a/harmonizer.c
+++ b/harmonizer.c
@@ -192,7 +192,7 @@ void harmonizer_init_pop(t_harmonizer *x)
{
// i go up
rnd = rand()/((double)RAND_MAX + 1);
- steps = rnd * 5; // how many steps (good notes) will I ignore?
+ steps = rnd * 10; // how many steps (good notes) will I ignore?
note = insertpoint + steps;
if (note >= POSSIBLE_NOTES)
note = POSSIBLE_NOTES-1;
@@ -201,7 +201,7 @@ void harmonizer_init_pop(t_harmonizer *x)
{
// i go down
rnd = rand()/((double)RAND_MAX + 1);
- steps = rnd * 5; // how many steps (good notes) will I ignore?
+ steps = rnd * 10; // how many steps (good notes) will I ignore?
note = insertpoint - steps;
if (note < 0)
note = 0;
@@ -223,7 +223,8 @@ void harmonizer_free(t_harmonizer *x)
// here i evaluate this voicing
int fitness(t_harmonizer *x, int *candidate)
{
- int i, j, tmp, res, last, avgHI, avgLOW;
+ int i, j, tmp, res, last, avgHI, avgLOW, min, max, distance;
+ float wideness, ftmp;
short int chord_notes[4];
short int chord_notes_ok[4];
short int transitions[VOICES];
@@ -337,7 +338,7 @@ int fitness(t_harmonizer *x, int *candidate)
{
if (DEBUG_VERBOSE)
post("transitions[%i] = %i",i, transitions[i]);
- res-=abs(transitions[i]);
+ res-=abs(transitions[i]) * x->small_intervals;
// give an incentive for semitones etc..
if (transitions[i]==0)
res += 5;
@@ -417,7 +418,14 @@ int fitness(t_harmonizer *x, int *candidate)
case 4: res -= 30; break;
}
-
+ // now wideness
+ min = notes[0];
+ max = notes[VOICES-1];
+ distance = max - min;
+ wideness = (float) (((float)distance) / ((float)12));
+ ftmp = fabs(wideness - x->wideness);
+ res -= ftmp * 5;
+
if (DEBUG_VERBOSE)
post("fitness is %i", res);