comparison data/fft/FFTDataServer.cpp @ 226:a867be73b638

* Add non-fftw3 fft alternative
author Chris Cannam
date Fri, 09 Feb 2007 11:32:34 +0000
parents bf753a9abf0c
children 3e6fee4e4257
comparison
equal deleted inserted replaced
225:185454896a76 226:a867be73b638
581 for (size_t i = 0; i <= m_width / m_cacheWidth; ++i) { 581 for (size_t i = 0; i <= m_width / m_cacheWidth; ++i) {
582 m_caches.push_back(0); 582 m_caches.push_back(0);
583 } 583 }
584 584
585 m_fftInput = (fftsample *) 585 m_fftInput = (fftsample *)
586 fftwf_malloc(fftSize * sizeof(fftsample)); 586 fftf_malloc(fftSize * sizeof(fftsample));
587 587
588 m_fftOutput = (fftwf_complex *) 588 m_fftOutput = (fftf_complex *)
589 fftwf_malloc((fftSize/2 + 1) * sizeof(fftwf_complex)); 589 fftf_malloc((fftSize/2 + 1) * sizeof(fftf_complex));
590 590
591 m_workbuffer = (float *) 591 m_workbuffer = (float *)
592 fftwf_malloc((fftSize+2) * sizeof(float)); 592 fftf_malloc((fftSize+2) * sizeof(float));
593 593
594 m_fftPlan = fftwf_plan_dft_r2c_1d(m_fftSize, 594 m_fftPlan = fftf_plan_dft_r2c_1d(m_fftSize,
595 m_fftInput, 595 m_fftInput,
596 m_fftOutput, 596 m_fftOutput,
597 FFTW_ESTIMATE); 597 FFTW_ESTIMATE);
598 598
599 if (!m_fftPlan) { 599 if (!m_fftPlan) {
600 std::cerr << "ERROR: fftwf_plan_dft_r2c_1d(" << m_windowSize << ") failed!" << std::endl; 600 std::cerr << "ERROR: fftf_plan_dft_r2c_1d(" << m_windowSize << ") failed!" << std::endl;
601 throw(0); 601 throw(0);
602 } 602 }
603 603
604 m_fillThread = new FillThread(*this, fillFromColumn); 604 m_fillThread = new FillThread(*this, fillFromColumn);
605 } 605 }
640 { 640 {
641 #ifdef DEBUG_FFT_SERVER 641 #ifdef DEBUG_FFT_SERVER
642 std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "]): deleteProcessingData" << std::endl; 642 std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "]): deleteProcessingData" << std::endl;
643 #endif 643 #endif
644 if (m_fftInput) { 644 if (m_fftInput) {
645 fftwf_destroy_plan(m_fftPlan); 645 fftf_destroy_plan(m_fftPlan);
646 fftwf_free(m_fftInput); 646 fftf_free(m_fftInput);
647 fftwf_free(m_fftOutput); 647 fftf_free(m_fftOutput);
648 fftwf_free(m_workbuffer); 648 fftf_free(m_workbuffer);
649 } 649 }
650 m_fftInput = 0; 650 m_fftInput = 0;
651 } 651 }
652 652
653 void 653 void
1039 fftsample temp = m_fftInput[i]; 1039 fftsample temp = m_fftInput[i];
1040 m_fftInput[i] = m_fftInput[i + m_fftSize/2]; 1040 m_fftInput[i] = m_fftInput[i + m_fftSize/2];
1041 m_fftInput[i + m_fftSize/2] = temp; 1041 m_fftInput[i + m_fftSize/2] = temp;
1042 } 1042 }
1043 1043
1044 fftwf_execute(m_fftPlan); 1044 fftf_execute(m_fftPlan);
1045 1045
1046 fftsample factor = 0.0; 1046 fftsample factor = 0.0;
1047 1047
1048 for (size_t i = 0; i <= m_fftSize/2; ++i) { 1048 for (size_t i = 0; i <= m_fftSize/2; ++i) {
1049 1049