简体   繁体   English

使用IIR滤波器生成粉红噪声

[英]Pink Noise Generation with IIR filter

I implement the following code from `'Proceedings of the IEEE'', N. Jeremy Kasdin (page 825) pdf . 我从''IEEE会议论文集',N。Jeremy Kasdin(第825页) pdf中实现了以下代码。 But I don't understand theses lines because I don't have Numerical Recipes book : 但我不明白这些线,因为我没有数字食谱书:

/* perform the discrete Fourier transform */  
realft (hfa,n_pts, 1); 
realft (wfa,n_pts, 1);

wfa[1]=wfa[1]*hfa[1]; 
wfa[2]=wfa[2]*hfa[2]; 

for(i=3;i<=nn;i+=2) { 
wr=wfa[i]; 
wi=wfa[i+1]; 
wfa[il=wr*hfa[i]-wi*hfa[i+1]; 
wfa[i+l]=wr*hfa[i+1]+wi*hfa[i];
}

Can someone give me some directions ? 有人可以给我一些指示吗?

The realft function in NR does the following. NR中的realft功能执行以下操作。 You feed it an array of N real numbers. 你喂它一个N个实数的数组。 (N has to be a power of 2.) The discrete Fourier transform of this consists of N complex numbers that obey a conjugate-symmetry relation: F(k) and F(Nk) are conjugate. (N必须是2的幂。)其离散傅立叶变换由遵循共轭 - 对称关系的N个复数组成:F(k)和F(Nk)是共轭的。 In particular, F(0) and F(N/2) are real. 特别地,F(0)和F(N / 2)是实数。 So realft returns N real numbers, as follows: F(0), F(N/2), real part of F(1), imaginary part of F(1), real part of F(2), ..., imaginary part of F(N/2-1). 因此, realft返回N个实数,如下:F(0),F(N / 2),F(1)的实部,F(1)的虚部,F(2)的实部,......, F(N / 2-1)的虚部。

NR was originally all Fortran, and (at least in older editions) uses 1-based indexing instead of 0-based. NR最初都是Fortran,并且(至少在旧版本中)使用基于1的索引而不是基于0的索引。 Even in C. That's why the code starts by operating on element 1 and runs up to nn inclusively rather than exclusively. 即使在C语言中也是如此。这就是为什么代码从元素1开始运行并且包含nn而不是排他性的。

So, you've taken the FT of hfa and wfa , in place. 所以,你已经采用了hfawfa的FT。 The rest of the code is simply computing the elementwise product of the results -- the first two lines are simple real multiplications, and the rest is multiplying complex numbers. 代码的其余部分只是计算结果的元素乘积 - 前两行是简单的实数乘法,其余的是乘以复数。

I'll guess that after that there's another call to realft with -1 as the last argument (meaning to do the inverse operation). 我猜测之后会再次调用realft其中-1为最后一个参数(意味着执行逆操作)。 So the whole thing is: FT of hfa and of wfa ; 所以整个事情是: hfawfa FT; multiply them elementwise; 将它们乘以元素; inverse FT. 逆FT。 In other words, a convolution. 换句话说,卷积。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM