// A much fucking simpler approach to generating musical patterns. // The state of an iteration is a byte, interpreted as a base-4 number // with 4 digits. Each digit indexes one level of indirection. typedef unsigned char note_val, position; enum { width = 8, width_mask = width - 1 }; typedef unsigned char score[4][width][4]; void generate_score(score *sc); note_val next_note(position pos, score *sc, int track); int freq(note_val n); void mutate_score(score *sc);