【问题标题】:Recombining phase and magnitude of sin wave?重新组合正弦波的相位和幅度?
【发布时间】:2021-05-24 16:04:19
【问题描述】:

我一直致力于音频信号的去相关。我正在关注一篇研究论文,其中该技术是以这样一种方式生成一个序列号,即幅度是恒定的,而相位是随机变化的。
现在,问题是我生成了一个正弦波,并对其进行了 fft,使用 NumPy 计算了相位和幅度,如下面的代码所示。

import numpy as np
from scipy.fftpack import fft, rfft, ifft, irfft

Farendsig = ((np.sin(2 * np.pi * np.arange(48000 * 0.02133) * 2000 / 48000)) * 32767).astype(np.int16)

freq = fft(Farendsig, 1024)  # fft output complex

phase = np.angle(freq)  # phase

magnitude = np.abs(freq)  # magnitude

combined = np.multiply(magnitude, np.exp(1j * phase))

FarendSyth = (ifft(combined, 1024) * (32767 + 0j)).astype(np.int16)

现在,当我按照 StackOverflow 的答案重新合成相同的信号时:How to combine the phase of one image and magnitude of the different image into 1 image by using python 。结果信号在某些指标上与原始信号不同。
我在这里做什么错了?

谢谢。

【问题讨论】:

    标签: numpy scipy signal-processing fft


    【解决方案1】:

    没关系,我找到了答案:

    FarendSyth = (ifft(combined, 1024)).astype(np.int1
    

    我将 ifft 结果与32767 相乘,这导致了结果中的问题。在上面的代码中替换这一行得到了准确的结果。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 2013-02-11
      • 2016-07-10
      • 2017-04-10
      • 2021-02-26
      相关资源
      最近更新 更多