def check_onset(audio):
# Determine if there is an 'early' onset
b_lpf, a_lpf = signal.butter(1, 200/44100.0, 'low')
sim = numpy.square(audio)
audio_lpf = signal.filtfilt(b_lpf,a_lpf,sim)
thres = 0.015
invert = 0
found = 0
for i in xrange(len(audio)):
if ((audio_lpf[i] > thres) and not found):
if (i < 4000):
print "Detected onset for ",fil," at time ",i/44.1," msecs "
found = 1
invert = 1
return invert
评论列表
文章目录