def slow_down_sound(sound, rate):
""" returns a sound which is a slowed down version of the original.
rate - at which the sound should be slowed down. eg. 0.5 would be half speed.
"""
raise NotImplementedError()
grow_rate = 1 / rate
# make it 1/rate times longer.
a1 = sndarray.array(sound)
surf = pygame.surfarray.make_surface(a1)
print (a1.shape[0] * grow_rate)
scaled_surf = pygame.transform.scale(surf, (int(a1.shape[0] * grow_rate), a1.shape[1]))
print (scaled_surf)
print (surf)
a2 = a1 * rate
print (a1.shape)
print (a2.shape)
print (a2)
sound2 = sndarray.make_sound(a2.astype(int16))
return sound2
评论列表
文章目录