def randomize_notes(self):
     """
     Randomizes a random number of notes. Used a mutation function.
     """
     n = random.randint(0, len(self))
     for k in range(0, n):
         i = random.randint(0, len(self))
         self.notes[0] = Note.get_random()
Exemple #2
0
    def get_random(min_length):
        min_length = config.musical.TICKS_PER_BEAT * min_length
        dur = 0
        notes = []
        while dur < min_length:
            new = Note.get_random()
            dur += new.ticks()
            notes.append(new)

        return Notes(notes)