From 6c68d11532edd534af2b877eeba6a36fcca460f1 Mon Sep 17 00:00:00 2001 From: Davide Morelli Date: Sat, 11 Feb 2006 15:18:22 +0000 Subject: notes are sorted, makefile for VCToolKit svn path=/trunk/externals/frankenstein/; revision=4579 --- harmonizer.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/harmonizer.c b/harmonizer.c index 2912291..56180f9 100755 --- a/harmonizer.c +++ b/harmonizer.c @@ -590,8 +590,10 @@ void generate_voicing(t_harmonizer *x) double rnd; //t_atom lista[VOICES]; t_atom *lista; + int *winner_notes; lista = malloc(sizeof(t_atom)*x->voices); + winner_notes = malloc(sizeof(int)*x->voices); // inizialize tables of notes build_possible_notes_table(x); @@ -640,7 +642,13 @@ void generate_voicing(t_harmonizer *x) for (i=0;ivoices;i++) { - SETFLOAT(lista+i, x->population[winner][i]); + winner_notes[i] = x->population[winner][i]; + } + SGLIB_ARRAY_SINGLE_QUICK_SORT(int, winner_notes, x->voices, SGLIB_NUMERIC_COMPARATOR) + + for (i=0;ivoices;i++) + { + SETFLOAT(lista+i, winner_notes[i]); } // send output array to outlet @@ -649,6 +657,7 @@ void generate_voicing(t_harmonizer *x) x->voices, lista); free(lista); + free(winner_notes); } // if i want another voicing i can send a bang @@ -659,20 +668,28 @@ static void harmonizer_bang(t_harmonizer *x) { // called when i send a list (with midi values) void set_current_voices(t_harmonizer *x, t_symbol *sl, int argc, t_atom *argv) { - int i=0; + int i=0; + int *input_voices; if (argcvoices) { error("insufficient notes sent!"); return; } + input_voices = malloc(sizeof(int)*x->voices); // fill input array with actual data sent to inlet for (i=0;ivoices;i++) { - x->current_voices[i] = atom_getint(argv++); + input_voices[i] = atom_getint(argv++); } - + SGLIB_ARRAY_SINGLE_QUICK_SORT(int, input_voices, x->voices, SGLIB_NUMERIC_COMPARATOR) + for (i=0;ivoices;i++) + { + x->current_voices[i] = input_voices[i]; + } + generate_voicing(x); + free(input_voices); } -- cgit v1.2.1