我正在使用FFTW在C++中創建頻譜分析儀。導致頻譜不等放大的FFT窗口
在對輸入信號應用任何窗口函數之後,輸出振幅似乎突然與頻率成比例。
Retangular窗口
EXACT-布萊克曼
圖形與44100赫茲的採樣頻率對數縮放。所有諧波都在同一電平上產生,峯值爲0dB,如矩形情況下所見。 Exact-Blackman窗口被放大了7.35dB,試圖進行化妝處理。
這裏是我的生成輸入表的代碼...
freq = 1378.125f;
for (int i = 0; i < FFT_LOGICAL_SIZE; i++)
{
float term = 2 * PI * i/FFT_ORDER;
for (int h = 1; freq * h < FREQ_NYQST; h+=1) // Harmonics up to Nyquist
{
fftInput[i] += sinf(freq * h * K_PI * i/K_SAMPLE_RATE); // Generate sine
fftInput[i] *= (7938/18608.f) - ((9240/18608.f) * cosf(term)) + ((1430/18608.f) * cosf(term * 2)); // Exact-Blackman window
}
}
fftwf_execute(fftwR2CPlan);
增加或減少窗口大小改變不了什麼。我也用漢明窗口測試過,同樣的問題。
這是我抓取輸出的代碼。
float val; // Used elsewhere
for (int i = 1; i < K_FFT_COMPLEX_BINS_NOLAST; i++) // Skips the DC and Nyquist bins
{
real = fftOutput[i][0];
complex = fftOutput[i][1];
// Grabs the values and scales based on the window size
val = sqrtf(real * real + complex * complex)/FFT_LOGICAL_SIZE_OVER_2;
val *= powf(20, 7.35f/20); // Only applied during Exact-Blackman test
}
奇怪的是,我試圖在Exact-Blackman案例中展示出這種反應。這種縮減導致了近乎但並非完全平坦的反應。整潔,但仍然沒有向我解釋爲什麼會發生這種情況。
float x = (float)(FFT_COMPLEX_BINS - i)/FFT_COMPLEX_BINS; // Linear from 0 to 1
x = log10f((x * 9) + 1.3591409f); // Now logarithmic from 0 to 1, offset by half of Euler's constant
val = sqrt(real * real + complex * complex)/(FFT_LOGICAL_SIZE_OVER_2/x); // Division by x added to this line
斑點!就是這樣!非常感謝! – Krunklehorn