void compute_tactus_scores(void) { /* This goes through and finds the best k for each j at each pip (by calling "best score") */ int pip, j, k; for (pip=0; pip<N_pips; pip++) { for (j=min_pip; j<=max_pip; j++) { pip_array[pip].score[nscore(j)] = best_score(pip, j, &k, FALSE); } } }
void label_beats(int pip, int j, int level) { /* this labels the beats and it also fills in the best_j fields of the pip_array (Having chosen the best last beat, this traces it back and makes the whole best level explicit) */ int k; while (1) { pip_array[pip].is_beat[level] = 1; pip_array[pip].best_j = j; if (pip-j < 0) { first_beat[level] = pip; /* printf("The first beat at level %d is at pip %d\n", level, pip); */ break; } best_score(pip, j, &k, level == HIGHEST_LEVEL); pip -= j; j = k; } }
static value_t find_best_match(runtime_t *runtime, value_t current, value_t target, value_t current_score, value_t space, value_t *score_out) { if (value_identity_compare(current, target)) { *score_out = current_score; return success(); } else { TRY_DEF(parents, get_type_parents(runtime, space, current)); int64_t length = get_array_buffer_length(parents); value_t score = new_no_match_score(); for (int64_t i = 0; i < length; i++) { value_t parent = get_array_buffer_at(parents, i); value_t next_score = whatever(); TRY(find_best_match(runtime, parent, target, get_score_successor(current_score), space, &next_score)); score = best_score(score, next_score); } *score_out = score; return success(); } }