def mutate(octave, pitch, velocity, duration, offset, point): #def mutate(seq, pitch=0, duration=0, velocity=0, offset=0, octave=0): """ Transpose a point by an interval, using the Sebastian interval system """ octave_delta = random.randint(-1*octave,octave) rna = { 'midi_pitch':pitch, 'pitch':pitch, 'octave':octave, 'velocity':velocity, DURATION_64:duration, OFFSET_64:offset } new_point = Point() for key in rna: if key in point: if key == "octave": new_value = random.randint(point[key]-rna[key],point[key]+rna[key])+octave_delta if new_value < 0: new_value = random.randint(point[key]-rna[key],point[key]+rna[key])+(octave_delta*-1) print "was negative" else: new_value = random.randint(point[key]-rna[key],point[key]+rna[key]) new_point.__setitem__(key, new_value) return new_point
def mutate(seq, pitch=0, duration=0, velocity=0, offset=0, octave=0): output = [] octave_delta = random.randint(-1*octave,octave) for point in seq: rna = { 'midi_pitch':pitch, 'pitch':pitch, 'octave':octave, 'velocity':velocity, DURATION_64:duration, OFFSET_64:offset } new_point = Point() for key in rna: if key in point: if key == "octave": new_value = random.randint(point[key]-rna[key],point[key]+rna[key])+octave_delta else: new_value = random.randint(point[key]-rna[key],point[key]+rna[key]) new_point.__setitem__(key, new_value) output.append(new_point) return OSequence(output)