ifft(fft(audio))只是噪音 [英] ifft(fft(audio)) is just noise
问题描述
是将它们嵌套(iff(fft(audio))
)还是尝试逐窗口显示(window
音频,执行fft
,执行ifft
,然后反转窗口,用eps替换零,然后合并回样本(在管道中的此处和此处尝试abs
)),我只会得到噪音.
whether i just nest them (iff(fft(audio))
) or try window-by-window (window
the audio, do the fft
, do the ifft
, then invert the window, replacing zero with eps, then merge the samples back (trying abs
here and there in the pipelines)) i get only noise.
我知道ifft
仅与fft
逆,具有无限精度算术,无限多个样本等(对吗?),我正在使用64位浮点和44kHZ采样率.但是,我希望至少能够听到原始音频.
i know the ifft
is only inverse to the fft
with infinite precision arithmetic, infinitely many samples, etc (right?) i'm working with 64bit floating point and 44kHZ sample rate. but, i would expect to be able to at least hear the original audio.
我的错误是实用的还是理论的?如果有错误,我可以给出代码.
is my error practical or theoretical? i can give code, if it's a bug.
推荐答案
Building on JoeKington's comment, I have downloaded this file, and tried the following
>>> import scipy.io.wavfile
>>> rate, data = scipy.io.wavfile.read('wahoo.wav')
>>> data
array([134, 134, 134, ..., 124, 124, 124], dtype=uint8)
>>> data_bis = np.fft.ifft(np.fft.fft(data))
>>> data_bis
array([ 134. +6.68519934e-14j, 134. -4.57982480e-14j,
134. -1.78967708e-14j, ..., 124. -2.09835513e-14j,
124. -1.61750469e-14j, 124. -2.14867343e-14j])
>>> data_bis = data_bis.astype('uint8')
C:\Users\Jaime y Eva\Desktop\stack_exchange.py:1: ComplexWarning: Casting complex values to real discards the imaginary part
# -*- coding: utf-8 -*-
>>> data_bis
array([134, 133, 133, ..., 123, 123, 123], dtype=uint8)
>>> scipy.io.wavfile.write('wahoo_bis.wav', rate, data_bis)
结果文件的播放与原始文件完全相同.
And the resulting file plays exactly the same as the original one.
因此将返回的复数值转换为实数仅是问题的一半(并且您可能想使用np.abs
而不是data.real
,就像上面的代码隐式地一样),然后还需要重铸浮点数点号到适当的位深度的uint
.
So turning the return complex values into reals is only half the problem (and you may want to go with np.abs
rather than data.real
, as the code above implicitly does), and you then also need to recast your floating point numbers to uint
s of the apropriate bit-depth.
这篇关于ifft(fft(audio))只是噪音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!