在 python 中获取 FFT 波形以匹配 Adob​​e Audition 频率分析

Get FFT waveform in python to match Adobe Audition Frequency Analysis

对于找到的 wav 文件 here,我想匹配 Adob​​e Audition 中显示的频谱:

目前,我使用的代码:

import scipy.io.wavfile as wavfile
import scipy
import scipy.fftpack
import numpy as np
from matplotlib import pyplot as plt


file1 = (r'G:/file1.wav')

fs_rate, signal = wavfile.read(file1)
print ("Frequency sampling", fs_rate)
l_audio = len(signal.shape)
print ("Channels", l_audio)
if l_audio == 2:
    signal = signal.sum(axis=1) / 2
N = signal.shape[0]
print ("Complete Samplings N", N)
secs = N / float(fs_rate)
print ("secs", secs)
Ts = 1.0/fs_rate # sampling interval in time
print ("Timestep between samples Ts", Ts)
t = np.arange(0, secs, Ts) # time vector as scipy arange field / numpy.ndarray
FFT = scipy.fftpack.fft(signal)
FFT_side = FFT[range(N//2)] # one side FFT range
freqs = scipy.fftpack.fftfreq(signal.size, t[1]-t[0])
fft_freqs = np.array(freqs)
freqs_side = freqs[range(N//2)] # one side frequency range
fft_freqs_side = np.array(freqs_side)

plt.plot(freqs_side/1000, 2.0/N * abs(FFT_side))
plt.xlabel('Frequency (kHz)')
plt.ylabel('Count single-sided')

plt.show()

我得到这个情节:

你能帮我得到和 Adob​​e Audition Frequency Analysis 中显示的一样的情节吗window?

任何帮助将不胜感激!

使用 scipy.signal.welch 中的示例:

fs_rate, signal = wavfile.read(file1)
f, Pxx_den = scipy.signal.welch(signal, fs_rate, nperseg=512, window='blackmanharris')
plt.semilogy(f, Pxx_den)
plt.semilogx(f, Pxx_den)
plt.xlabel('frequency [Hz]')
plt.show()

y 轴单位已关闭,但这应该可以帮助您入门。