Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def scratch(audio, coordinate = False):
"""
This function performs scratching effects to sound arrays
:param audio: the signal you want to scratch
:param coordinate: to set this to True, a decision variable must be given (a distance) to use a velocity given a learned distance
:returns:
- scratched signal
"""
proportion = range(len(audio))[0:len(audio):len(audio)/16]
prop = overlapped_intervals(proportion)
audio = NoiseAdder(level = -100)(audio) #create noisy part for vinyl in turntable
audio = LowPass(cutoffFrequency = 22050)(audio)
audio = LowPass(cutoffFrequency = 30)(audio)
def hand_move(audio, rev_audio, prop, slices): #simulation of hand motion in a turntable
if (coordinate == False) or (coordinate == None):
forwards = np.concatenate([speedx(audio[i[0]:i[1]], randint(2,3)) for i in prop])
backwards = np.concatenate([speedx(rev_audio[i[0]:i[1]], randint(2,3)) for i in prop])
else:
factor = distance_velocity(audio, coordinate)
forwards = np.concatenate([speedx(audio[i[0]:i[1]], factor) for i in prop])
backwards = np.concatenate([speedx(audio[i[0]:i[1]], factor) for i in prop])
cf = crossfade(forwards, backwards, slices)
return cf
rev_audio = audio[::-1]
hand_a = lambda: hand_move(audio, rev_audio, prop, slices = [prop, prop])
hand_b = lambda: hand_move(audio, rev_audio, prop, slices = [prop[:12], prop[:12]])
hand_c = lambda: hand_move(audio, rev_audio, prop, slices = [prop[1:], prop])