예제 #1
0
파일: FFT.cpp 프로젝트: Vocaluxe/Vocaluxe
/*
 * InverseRealFFT
 *
 * This function computes the inverse of RealFFT, above.
 * The RealIn and ImagIn is assumed to be conjugate-symmetric
 * and as a result the output is purely real.
 * Only the first half of RealIn and ImagIn are used due to this
 * symmetry assumption.
 */
void InverseRealFFT(int NumSamples, float *RealIn, float *ImagIn, float *RealOut)
{
   // Remap to RealFFTf() function
   int i;
   HFFT hFFT = GetFFT(NumSamples);
   float *pFFT = new float[NumSamples];
   // Copy the data into the processing buffer
   for(i=0; i<(NumSamples/2); i++)
      pFFT[2*i  ] = RealIn[i];
   if(ImagIn == NULL) {
      for(i=0; i<(NumSamples/2); i++)
         pFFT[2*i+1] = 0;
   } else {
      for(i=0; i<(NumSamples/2); i++)
         pFFT[2*i+1] = ImagIn[i];
   }
   // Put the fs/2 component in the imaginary part of the DC bin
   pFFT[1] = RealIn[i];

   // Perform the FFT
   InverseRealFFTf(pFFT, hFFT);

   // Copy the data to the (purely real) output buffer
   ReorderToTime(hFFT, pFFT, RealOut);

   delete [] pFFT;
   ReleaseFFT(hFFT);
}
예제 #2
0
파일: FFT.cpp 프로젝트: MindFy/audacity
/*
 * InverseRealFFT
 *
 * This function computes the inverse of RealFFT, above.
 * The RealIn and ImagIn is assumed to be conjugate-symmetric
 * and as a result the output is purely real.
 * Only the first half of RealIn and ImagIn are used due to this
 * symmetry assumption.
 *
 * This is merely a wrapper of InverseRealFFTf() from RealFFTf.h.
 */
void InverseRealFFT(size_t NumSamples, const float *RealIn, const float *ImagIn,
		    float *RealOut)
{
   auto hFFT = GetFFT(NumSamples);
   Floats pFFT{ NumSamples };
   // Copy the data into the processing buffer
   for (size_t i = 0; i < (NumSamples / 2); i++)
      pFFT[2*i  ] = RealIn[i];
   if(ImagIn == NULL) {
      for (size_t i = 0; i < (NumSamples / 2); i++)
         pFFT[2*i+1] = 0;
   } else {
      for (size_t i = 0; i < (NumSamples / 2); i++)
         pFFT[2*i+1] = ImagIn[i];
   }
   // Put the fs/2 component in the imaginary part of the DC bin
   pFFT[1] = RealIn[NumSamples / 2];

   // Perform the FFT
   InverseRealFFTf(pFFT.get(), hFFT.get());

   // Copy the data to the (purely real) output buffer
   ReorderToTime(hFFT.get(), pFFT.get(), RealOut);
}