def rfft(x):
if use_numpy_rfft:
y = numpy.fft.rfft(x)
return y
else:
assert (len(x) % 2) == 0
y = scipy.fftpack.rfft(x)
if type(y[0]) == numpy.float32:
cty = numpy.complex64
elif type(y[0]) == numpy.float64:
cty = numpy.complex128
else:
assert False
# y = [ Re0, Re1, Im1, Re2, Im2, ..., ReN ]
y1 = y[1:-1].view(cty)
y = numpy.concatenate((y[0:1], y1, y[-1:]))
return y
# apply automatic gain control.
# causes each winlen window of samples
# to have average absolute value of 1.0.
# winlen is in units of samples.
评论列表
文章目录