title: FFTW results in zeros
body: <p>I'm trying to get FFTW to work in C. It used to work for another project (which was in JNI), and I'm more or less copying the code from that one, sadly without results.</p>
  
  <p>First I generate a sine signal, like this:</p>
  
  <pre><code>double* generateSignal() {
      int fs=44100;
      double fsd = 44100.0; // fs in double format
      double f1=1000.0;
      int i;
      double PI = 3.141592653589793238462643;
  
      double t[fs];
      double value = 0.0;
      for (i = 0; i &lt; fs; i++) {
          t[i] = value;
          value += 1.0/fsd;
      }
  
      double* signal = (double*) malloc(sizeof(double) * fs);
      for (i = 0; i &lt; fs; i++) {
          signal[i] = sqrt(2) * sin(2 * PI * f1 * t[i]);
      }
  
      return signal;
  }    
  </code></pre>
  
  <p>This works, I'm only posting it for completeness. </p>
  
  <p>Next, I want to transform the signal using FFTW, which I do in the following method (based on the <a href="http://fftw.org/doc/Complex-One_002dDimensional-DFTs.html#Complex-One_002dDimensional-DFTs" rel="nofollow">FFTW documentation</a>):</p>
  
  <pre><code>void processSignal(double* signal) {
      int size = 44100;
      int i;
  
      fftw_complex* in = fftw_malloc(sizeof(fftw_complex) * size);
      fftw_complex* out = fftw_malloc(sizeof(fftw_complex) * size);
  
      for (i = 0; i &lt; size; i++) {
          double* ptr = in[i];
          *ptr = signal[i];       // set first double, real part
          *(ptr + 1) = 0.0;       // set second double, imaginary part
      }
  
      fftw_plan p = fftw_plan_dft_1d(size, in, out, FFTW_FORWARD, FFTW_ESTIMATE); 
      fftw_execute(p);
  
      for (i = 0; i &lt; size; i++) {
          double* ptr = out[i];
          signal[i] = *ptr;       // get real part
      }
  
      fftw_destroy_plan(p);
      fftw_free(in);
      fftw_free(out);
  }
  </code></pre>
  
  <p>Please note this from the FFTW documentation: <code>typedef double fftw_complex[2];</code></p>
  
  <p>Now, this results in all values of the <code>signal</code>-array being -0.000000. I really can't see the problem with this code, so could any please point out what I'm doing wrong?</p>
  
  <p>Thanks.</p>
  
  <p>PS: Dropped the print-statements from my code for clarity.</p>