def ensure_melody(self, melody): """Ensure that the four-part harmony has a complete or partial melody as its soprano line.""" for t, note in enumerate(melody): if not note: continue constraint = self.notes[denote(note), 3, t] == 1 self.model.addConstr(constraint, "melody_t" + str(t)) self.model.update()
# (Note: model is untested on anything other than default parameters) max_pitch = 60 voice_count = 4 # What is the maximum semitone interval allowed between consecutive pitches in # the same voice? max_interval = 6 # What vocal ranges should each of the voices use? voice_ranges = [ range(denote("g"), denote("d'")), range(denote("c"), denote("g'")), range(denote("g"), denote("d''")), range(denote("c'"), denote("c'''")) ] # Chord progression matrix (phi) chord_progressions = { # {"I", "I6", "I64", "ii", "ii6", "iii", "iii6", "IV", "IV6", "IV64", "V", "V6", "V64", "V7", "V75", "V43", "V2", "vi", "vi6", "vii6"}, "I": { "I6", "I64", "ii", "ii6", "iii", "iii6", "IV", "IV6", "IV64", "V", "V6", "V64", "V7", "V75", "V43", "V2", "vi", "vi6", "vii6"}, "I6": {"I", "I64", "ii", "ii6", "iii", "iii6", "IV", "IV6", "IV64", "V", "V6", "V64", "V7", "V75", "V43", "V2", "vi", "vi6", "vii6"}, "I64": { "V", "V7", }, "ii": { "ii6", "V", "V6", "V7", "V75", "V43", "V2", "vii6"}, "ii6": { "ii", "V", "V6", "V7", "V75", "V43", "V2", "vii6"},