CUFFT set frequency of fft

I am using CUDA’s Cufft to process data i receive from a hydrophone(500,000 integers a second at 250hertz). Now as a basic example of how Cufft works is here…

void runTest(int argc, char** argv)

{

printf("[1DCUFFT] is starting...\n");


cufftComplex* h_signal = (cufftComplex*)malloc(sizeof(cufftComplex)* SIGNAL_SIZE);
// Allocate host memory for the signal
//Complex* h_signal = (Complex*)malloc(sizeof(Complex) * SIGNAL_SIZE);
// Initalize the memory for the signal
for (unsigned int i = 0; i < SIGNAL_SIZE; ++i) {
    h_signal[i].x = rand() / (float)RAND_MAX;
    h_signal[i].y = 0;
}




int mem_size = sizeof(cufftComplex)* SIGNAL_SIZE;

// Allocate device memory for signal
cufftComplex* d_signal;
cudaMalloc((void**)&d_signal, mem_size);

// Copy host memory to device
cudaMemcpy(d_signal, h_signal, mem_size,
    cudaMemcpyHostToDevice);



// CUFFT plan
cufftHandle plan;
cufftPlan1d(&plan, mem_size, CUFFT_C2C, 1);

// Transform signal 
printf("Transforming signal cufftExecC2C\n");
cufftExecC2C(plan, (cufftComplex *)d_signal, (cufftComplex *)d_signal, CUFFT_FORWARD);


// Transform signal back
printf("Transforming signal back cufftExecC2C\n");
cufftExecC2C(plan, (cufftComplex *)d_signal, (cufftComplex *)d_signal, CUFFT_INVERSE);

// Copy device memory to host
cufftComplex* h_inverse_signal = (cufftComplex*)malloc(sizeof(cufftComplex)* SIGNAL_SIZE);;
cudaMemcpy(h_inverse_signal, d_signal, mem_size,
    cudaMemcpyDeviceToHost);

for (int i = 0; i < SIGNAL_SIZE; i++){
    h_inverse_signal[i].x = h_inverse_signal[i].x / (float)SIGNAL_SIZE;
    h_inverse_signal[i].y = h_inverse_signal[i].y / (float)SIGNAL_SIZE;

    printf("first : %f %f  after %f %f \n", h_signal[i].x, h_signal[i].y, h_inverse_signal[i].x, h_inverse_signal[i].y);
}
//Destroy CUFFT context
cufftDestroy(plan);

// cleanup memory
free(h_signal);

free(h_inverse_signal);
cudaFree(d_signal);
cudaDeviceReset();
}

Now all I want to know is, how do i set the frequency of the FFT to be 250hertz?

Thanks

James

As was explained to you in your cross-posting:

[url]c++ - Cufft set frequency? - Stack Overflow

An FFT does not have “a frequency”. Some pointed comments there:

"An fft does not have a single frequency. It’s vector basis covers the entire range from DC (0 Hz) to Fs/2 "

“Your question is indeed misleading, which is reflected in the comments”

Posting the same question here is not likely to be any less misleading.

A fourier transform converts a signal in one domain to an equivalent signal in another domain. The usual usage is from time domain to frequency domain. A discrete FT (of which FFT is a type) will transform a discrete (i.e. sampled, rather than continuous-valued) signal.

The fourier transform itself does not define particular frequencies, except as derivatives of the size (N) of the transform and the underlying sample frequency (Fs) that are inherent properties of the original signal.

You might want to:

  1. Get a little more knowledge of FFT under your belt
  2. Be more specific about what frequency aspects of the transform you are interested in.