def choose_melody_notes(self, duration, harmonies, bar_type): # return a list of {pitch, duration} dicts notes = [] # choose a register # register = self.choose_violin_register() # register_by_pitch_classes = defaultdict(list) # for p in register: # register_by_pitch_classes[p % 12].append(p) rhythm = get_melody_rhythm(duration) # One in four bars that have more than 3 notes will start with a rest start_with_rest = False if rhythm[0] <= 1.0: if len(rhythm) > 2 and random.random() < .4: start_with_rest = True for r in rhythm: notes.append({ 'pitch': None, 'duration': r }) self.choose_melody_pitches( notes, bar_type.register, harmonies, start_with_rest ) notes = self.add_ornaments(notes) return notes
def choose_melody_notes(self, duration, harmonies): # return a list of {pitch, duration} dicts notes = [] # choose a register # register = self.choose_violin_register() # register_by_pitch_classes = defaultdict(list) # for p in register: # register_by_pitch_classes[p % 12].append(p) rhythm = get_melody_rhythm(duration) for r in rhythm: notes.append({'pitch': None, 'duration': r}) self.choose_melody_pitches(notes, self.vln_register, harmonies) notes = self.add_ornaments(notes) return notes
def choose_melody_notes(self, duration, harmonies): # return a list of {pitch, duration} dicts notes = [] # choose a register # register = self.choose_violin_register() # register_by_pitch_classes = defaultdict(list) # for p in register: # register_by_pitch_classes[p % 12].append(p) rhythm = get_melody_rhythm(duration) for r in rhythm: notes.append({ 'pitch': None, 'duration': r }) self.choose_melody_pitches(notes, self.vln_register, harmonies) notes = self.add_ornaments(notes) return notes