fftw

generating correct spectrogram using fftw and window function

大城市里の小女人 提交于 2019-12-20 14:20:10
问题 For a project I need to be able to generate a spectrogram from a .WAV file. I've read the following should be done: Get N (transform size) samples Apply a window function Do a Fast Fourier Transform using the samples Normalise the output Generate spectrogram On the image below you see two spectrograms of a 10000 Hz sine wave both using the hanning window function. On the left you see a spectrogram generated by audacity and on the right my version. As you can see my version has a lot more

WAV-file analysis C (libsndfile, fftw3)

南笙酒味 提交于 2019-12-20 09:42:52
问题 I'm trying to develop a simple C application that can give a value from 0-100 at a certain frequency range at a given timestamp in a WAV-file. Example: I have frequency range of 44.1kHz (typical MP3 file) and I want to split that range into n amount of ranges (starting from 0). I then need to get the amplitude of each range, being from 0 to 100. What I've managed so far: Using libsndfile I'm now able to read the data of a WAV-file. infile = sf_open(argv [1], SFM_READ, &sfinfo); float samples

Implement Hann Window

旧街凉风 提交于 2019-12-18 10:46:45
问题 I take blocks of incoming data and pass them through fftw to get some spectral information. Everything seems to be working, however I think I'm getting some aliasing issues. I've been trying to work out how to implement a hann window on my blocks of data. Google has failed me for examples. Any ideas or links I should be looking at? double dataIn[2048] > /* windowing here? */ > FFT > double freqBins[2048] Update Thanks to Oli for pointing out the issue I'm actually trying to fix is spectral

How to do a fftw3 MPI “transposed” 2D transform if possible at all?

不问归期 提交于 2019-12-18 09:07:18
问题 Consider a 2D transform of the form L x M (column major setup), from a complex array src to a real array tgt . Or , in Fortranese, complex(C_DOUBLE_COMPLEX), pointer :: src(:,:) real(8), pointer :: tgt(:,:) . Corresponding pointers are type(C_PTR) :: csrc,ctgt . I would allocate them in the following manner: ! The complex array first alloc_local = fftw_mpi_local_size_2d(M,L/2+1,MPI_COMM_WORLD,local_M,local_offset1) csrc = fftw_alloc_complex(alloc_local) call c_f_pointer(csrc, src, [L/2,local

Matlab FFT and FFTW

﹥>﹥吖頭↗ 提交于 2019-12-14 02:09:44
问题 I'm trying to have the same FFT with FFTW and Matlab. I use MEX files to check if FFTW is good. I think I have everything correct but : I get absurd values from FFTW, I do not get the same results when running the FFTW code several times on the same input signal. Can someone help me get FFTW right? -- EDIT 1 : I finally figured out what was wrong, BUT... FFTW is very unstable : I get the right spectrum 1 time out of 5 ! How come? Plus, when I get it right, it doesn't have symmetry (which is

FFTW on real data sequence

≡放荡痞女 提交于 2019-12-13 07:25:23
问题 I'm reading a raw sound file, and I' m trying to run the fft on it, with aim of getting the PSD at the end, but I'm in the start and I get an error that I can't understand, hope getting some help here, the code is: #include <stdio.h> #include <fftw3.h> int main(){ char* fileName = "sound.raw"; FILE* inp = NULL; double* data = NULL; int index = 0; fftw_plan plan; fftw_complex* out; double r,i; int N = 8192; //Allocating the memory for the input data data = (double*) fftw_malloc(sizeof(double)

Configure error installing fftw

妖精的绣舞 提交于 2019-12-13 06:46:51
问题 I just followed the instructions here to update my gcc. Now I am trying to install FFTW. So I downloaded the filed here. After I unzip and navigate to that directory I run this: ./configure --enable-mpi --enable-threads --enable-openmp But I get the following error: checking for OpenMP flag of C compiler... unknown configure: error: don't know how to enable OpenMP I know OpenMP didn't work before I updated GCC, but it does now if I do this: export PATH=/usr/local/gcc-6.1.0/bin:$PATH gcc-6.1.0

FFTW producing real instead of complex output

元气小坏坏 提交于 2019-12-13 04:44:11
问题 I'm using the following code to perform the COMPLEX IFFT of an array of complex numbers (I must get complex results): #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <math.h> #include <complex.h> #include <fftw3.h> int main(void) { fftw_complex *in; fftw_complex *out; double re,im; int size; int i=0; FILE *file; fftw_plan ifft; printf("Insert size"); if (scanf("%d", &size) != 1 || size < 1) return 1; in = fftw_malloc(sizeof(*in)*size); out = fftw_malloc(sizeof(*out)*size);

DCT of complex arrays with FFTW in Fortran: How to point to the imaginary part array?

*爱你&永不变心* 提交于 2019-12-13 04:09:20
问题 I am writing a pseudo-spectral CFD code in Fortran, which is essentially a time-stepper of the Navier-Stokes equations in a plane layer. It is really a 3d code in my case, but the problem can be very well understood in 2d, so I will stick to this case. Geometrically, my 2d plane layer is bounded by y=0 and y=1 , and is periodic along the other direction x . Without going too much into the weeds, an efficient discretisation is to decompose fields (e.g., velocity) on Chebyshev polynomials along

Return transformed nmatrix array with fftw3

别来无恙 提交于 2019-12-13 03:39:31
问题 I am creating a ruby wrapper for the fftw3 library for the Scientific Ruby Foundation which uses nmatrix objects instead of regular ruby arrays. I have a curious problem in returning the transformed array in that I am not sure how to do this so I can check the transform has been computed correctly against octave or (something like this) in my specs I have an idea that I might be best to cast the output array out which is an fftw_complex type to a VALUE to pass it to the nmatrix object before