From 91247c1545897354bd7dfd27cbe513609077fdb3 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 11 Jul 2021 19:24:42 -0400 Subject: [PATCH 01/26] Added comments (and testing push from VSCode). --- .../analyzers/WidthFramer/widthframerform.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 40c7f53d..6c5c7e2b 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -4,7 +4,6 @@ #include #include #include - #include WidthFramerForm::WidthFramerForm(QSharedPointer delegate) : @@ -140,10 +139,15 @@ void WidthFramerForm::widthSelected(QModelIndex index) QVector WidthFramerForm::autocorrelate(QSharedPointer bits) { + //left shift int N = 1 << 19; + + //reference: https://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html#Complex-One_002dDimensional-DFTs + //allocate input and output arrays fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + //create plans (read about arguments in the documentation) fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); From 36bf7f185945d0ffbd38e832057b8c81206df907 Mon Sep 17 00:00:00 2001 From: melissascode Date: Mon, 12 Jul 2021 14:24:31 -0400 Subject: [PATCH 02/26] Testing commit to my Hobbits fork. --- src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 6c5c7e2b..31d9be84 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -139,6 +139,8 @@ void WidthFramerForm::widthSelected(QModelIndex index) QVector WidthFramerForm::autocorrelate(QSharedPointer bits) { + //replace FFTW library + //left shift int N = 1 << 19; From 4be20f2c0071a7f8732cd6943bc47e172d37c848 Mon Sep 17 00:00:00 2001 From: melissascode Date: Wed, 4 Aug 2021 18:21:08 -0400 Subject: [PATCH 03/26] In the autocorrelate function (widthframerform.cpp), I commented out the code associated with the FFTW library. Added in new code that utilizes the PFFFT library in order to perform Fast Fourier Transforms needed. I updated CMakeLists.txt to include the PFFFT library. --- .../analyzers/WidthFramer/CMakeLists.txt | 1 + .../analyzers/WidthFramer/widthframerform.cpp | 85 ++++++++++++++++--- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt index 2ac9454a..279f501f 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt +++ b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt @@ -3,6 +3,7 @@ pluginInDir("${pluginType}" "WidthFramer" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE CONAN_PKG::fftw) + target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE CONAN_PKG::pffft) else() if(WIN32) target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE FFTW::Double) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 31d9be84..a40179a9 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -6,6 +6,12 @@ #include #include +#include "pffft.h" + + +#include +using namespace std; + WidthFramerForm::WidthFramerForm(QSharedPointer delegate) : ui(new Ui::WidthFramerForm()), m_delegate(delegate), @@ -144,18 +150,31 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b //left shift int N = 1 << 19; - //reference: https://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html#Complex-One_002dDimensional-DFTs - //allocate input and output arrays - fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); - fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + //allocate memory for the input and output arrays + //"array of type fftw_complex which is by default double[2]" + //fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + //fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + + //create set up for PFFFT + PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); + - //create plans (read about arguments in the documentation) - fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); - fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); + //create plans for FFTW + //fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); + //fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - // prepare and run first FFT + //allocate the arrays, or "float buffers," for input, output, and work + float *input = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); + float *output = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); + float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); + + +/* // prepare and run first FFT + //is this adding data to the fft_in array? for (int i = 0; i < N; i++) { + //real fft_in[i][0] = 0; + //imaginary fft_in[i][1] = 0; if (i < bits->sizeInBits()) { fft_in[i][0] = bits->at(i) ? 1 : -1; @@ -163,30 +182,74 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b fft_out[i][0] = 0; fft_out[i][1] = 0; } - fftw_execute(fft_plan1); +*/ + //and run first FFT (with PFFFT) + for (int i = 0; i < N; i++){ + input[i*2] = 0; //real + input[i*2+1] = 0; //imaginary + if (i < bits->sizeInBits()) { + input[i*2] = bits->at(i) ? 1 : -1; + } + output[i*2] = 0; + output[i*2+1]= 0; + } + - // prepare and run second FFT + //running the first FFT + //fftw_execute(fft_plan1); + + //running the first FFT (with PFFFT) + pffft_transform_ordered(setup, input, output, work, PFFFT_FORWARD); + + /* + // prepare and run second FFT for (int i = 0; i < N; i++) { double re = fft_out[i][0]; + //printf("%f \n", re); double im = fft_out[i][1]; + //printf("%f \n", im); fft_in[i][0] = (re * re + im * im) / static_cast(N); fft_in[i][1] = 0.0; } + //running the second FFT fftw_execute(fft_plan2); + */ + + for (int i = 0; i < N; i++) { + float re = output[i*2]; + float im = output[i*2+1]; + input[i*2] = (re * re + im * im) / static_cast(N); + input[i*2+1] = 0.0; + } + + //perform the second FFT (with PFFFT) + pffft_transform_ordered(setup, input, output, work, PFFFT_BACKWARD); + + // get results + //results vector size is equal to N / 2 QVector results(N / 2); + //insert at first index results.insert(0, QPointF(0, 0)); for (int i = 1; i < N / 2; i++) { - double re = qAbs(double(fft_out[i][0] / double(N))); + double re = qAbs(double(output[i*2] / double(N))); + //store in results vector results[i] = QPointF(i, re); } // clean up + /* fftw_destroy_plan(fft_plan1); fftw_destroy_plan(fft_plan2); fftw_free(fft_in); fftw_free(fft_out); + */ + pffft_aligned_free(work); + pffft_aligned_free(output); + pffft_aligned_free(input); + pffft_destroy_setup(setup); + return results; } From c89aaacac424f21b73eaeb314d65b97025de37c8 Mon Sep 17 00:00:00 2001 From: melissascode Date: Wed, 4 Aug 2021 18:39:26 -0400 Subject: [PATCH 04/26] Updated the renderDisplay function to use the PFFFT library methods to perform the Fast Fourier Transform. Changed the first parameter of the fillSamples function to be a float* buffer instead of fftw_complex* buffer. --- .../displays/Spectrogram/spectrogram.cpp | 206 +++++++++++++----- 1 file changed, 147 insertions(+), 59 deletions(-) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 2dfefccb..90f8d60a 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -7,6 +7,8 @@ #include "viridis.h" #include "displayresult.h" #include +#include "pffft.h" + Spectrogram::Spectrogram(): m_renderConfig(new DisplayRenderConfig()) @@ -102,9 +104,18 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con return DisplayResult::error(QString("Invalid sample format word size: %1").arg(sampleFormat.wordSize)); } - fftw_complex *fftIn = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(fftSize))); + /*fftw_complex *fftIn = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(fftSize))); fftw_complex *fftOut = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(fftSize))); fftw_plan plan = fftw_plan_dft_1d(fftSize, fftIn, fftOut, FFTW_FORWARD, FFTW_ESTIMATE); + */ + + //PFFFT set up + PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); + + //PFFFT allocate memory for input, output, and work arrays or "float buffers" + float *input = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); + float *output = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); + float *work = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); QVector hanningWindow(fftSize); for (int i = 0; i < fftSize; i++) { @@ -141,32 +152,51 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con QTime lastTime = QTime::currentTime(); for (int i = 0; i < spectRect.height(); i++) { if (!progress.isNull() && progress->isCancelled()) { - fftw_destroy_plan(plan); + /*fftw_destroy_plan(plan); fftw_free(fftIn); fftw_free(fftOut); + */ + pffft_aligned_free(work); + pffft_aligned_free(output); + pffft_aligned_free(input); + pffft_destroy_setup(s); return DisplayResult::error(QString("Render cancelled")); } if (currOffset + fftBits >= container->bits()->sizeInBits()) { break; } - fillSamples(fftIn, currOffset, container, sampleFormat, fftSize, dataType); + //fillSamples(fftIn, currOffset, container, sampleFormat, fftSize, dataType); + fillSamples(input, currOffset, container, sampleFormat, fftSize, dataType); - for (int i = 0; i < fftSize; i++) { + /*for (int i = 0; i < fftSize; i++) { fftIn[i][0] *= hanningWindow[i]; fftIn[i][1] *= hanningWindow[i]; + }*/ + + for(int i = 0; i < fftSize; i++){ + //handle the PFFFT arrays + input[i*2] *= hanningWindow[i]; + input[i*2+1] *= hanningWindow[i]; } - fftw_execute_dft(plan, fftIn, fftOut); + + //fftw_execute_dft(plan, fftIn, fftOut); + //running the first FFT (with PFFFT) + pffft_transform_ordered(s, input, output, work, PFFFT_FORWARD); QVector spectrum(fftSize/2); if (logarithmicScaling) { for (int n = 0; n < spectrum.size(); n++) { - spectrum[n] = log(outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1]))) / log(10); + //spectrum[n] = log(outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1]))) / log(10); + //not sure about the following line + spectrum[n] = log(outputFactor * ((output[n*2] * output[n*2]) + (output[i*2+1] * output[i*2+1]))) / log(10); } } else { for (int n = 0; n < spectrum.size(); n++) { - spectrum[n] = outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1])); + //spectrum[n] = outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1])); + //not sure about the following line + spectrum[n] = outputFactor * ((output[n*2] * output[n*2]) + (output[n*2+1] * output[n*2+1])); } } spectrums.append(spectrum); @@ -188,9 +218,14 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con } } - fftw_destroy_plan(plan); + /*fftw_destroy_plan(plan); fftw_free(fftIn); fftw_free(fftOut); + */ + pffft_aligned_free(work); + pffft_aligned_free(output); + pffft_aligned_free(input); + pffft_destroy_setup(s); setSpectrums(spectrums); QImage result(viewportSize, QImage::Format_ARGB32); @@ -472,7 +507,10 @@ QString Spectrogram::timeString(qint64 sample, double sampleRate) } } -void Spectrogram::fillSamples(fftw_complex* buffer, + +//COME TO THIS FUNCTION! FFTW STUFF NEEDS TO BE REPLACED WITH PFFFT +/*void Spectrogram::fillSamples(fftw_complex* buffer*/ +void Spectrogram::fillSamples(float* buffer, qint64 offset, QSharedPointer bitContainer, const MetadataHelper::SampleFormat &sampleFormat, @@ -492,14 +530,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(fBuffer[i*2]); - buffer[i][1] = double(fBuffer[i*2 + 1]); + //buffer[i][0] = double(fBuffer[i*2]); + //buffer[i][1] = double(fBuffer[i*2 + 1]); + buffer[i*2] = double(fBuffer[i*2]); + buffer[i*2+1] = double(fBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(fBuffer[i]); - buffer[i][1] = 0.0; + //buffer[i][0] = double(fBuffer[i]); + //buffer[i][1] = 0.0; + buffer[i*2] = double(fBuffer[i]); + buffer[i*2+1] = 0.0; } } delete[] fBuffer; @@ -510,14 +552,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]); - buffer[i][1] = double(sBuffer[i*2 + 1]); + //buffer[i][0] = double(sBuffer[i*2]); + //buffer[i][1] = double(sBuffer[i*2 + 1]); + buffer[i*2] = double(sBuffer[i*2]); + buffer[i*2+1] = double(sBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]); - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]); + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]); + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -528,14 +574,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -546,14 +596,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -564,14 +618,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -582,14 +640,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -600,14 +662,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -618,14 +684,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -636,14 +706,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -654,14 +728,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -672,14 +750,18 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = 0.0; } } delete[] sBuffer; @@ -690,22 +772,28 @@ void Spectrogram::fillSamples(fftw_complex* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i][0] = double(sBuffer[i*2]) / weight; - buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + //buffer[i][0] = double(sBuffer[i*2]) / weight; + //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = double(sBuffer[i*2]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i][0] = double(sBuffer[i]) / weight; - buffer[i][1] = 0.0; + //buffer[i][0] = double(sBuffer[i]) / weight; + //buffer[i][1] = 0.0; + buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } delete[] sBuffer; } for (qint64 i = samples; i < fftSize; i++) { - buffer[i][0] = 0.0; - buffer[i][1] = 0.0; + //buffer[i][0] = 0.0; + //buffer[i][1] = 0.0; + buffer[i*2] = 0.0; + buffer[i*2+1] = 0.0; } } From d017291b61a57b4bddc18eaab5988876e1f21766 Mon Sep 17 00:00:00 2001 From: melissascode Date: Wed, 4 Aug 2021 18:41:05 -0400 Subject: [PATCH 05/26] Altered the function parameters for fillSamples. I changed the first parameter from fftw_complex* buffer to float* buffer, as the PFFFT library makes use of float buffers. --- src/hobbits-plugins/displays/Spectrogram/spectrogram.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.h b/src/hobbits-plugins/displays/Spectrogram/spectrogram.h index 05f21918..0126bc60 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.h +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.h @@ -39,7 +39,7 @@ class Spectrogram : public QObject, DisplayInterface QSharedPointer displayHandle, const Parameters ¶meters); QString timeString(qint64 sample, double sampleRate); - void fillSamples(fftw_complex* buffer, + void fillSamples(float* buffer, qint64 offset, QSharedPointer bitContainer, const MetadataHelper::SampleFormat &sampleFormat, From a134e648a1cd2473ce7725ab43c1d33a30598f21 Mon Sep 17 00:00:00 2001 From: melissascode Date: Wed, 4 Aug 2021 18:42:15 -0400 Subject: [PATCH 06/26] Added PFFFT library to the building_with_conan section --- src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt index bc235538..3164a801 100644 --- a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt +++ b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt @@ -4,6 +4,7 @@ pluginInDir("${pluginType}" "Spectrogram" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE CONAN_PKG::fftw) + target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE CONAN_PKG::pffft) else() if(WIN32) target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE FFTW::Double) From 81ba931b4545e834664fc9e953112482233a516c Mon Sep 17 00:00:00 2001 From: melissascode Date: Wed, 4 Aug 2021 18:42:54 -0400 Subject: [PATCH 07/26] Added PFFFT library. --- conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index c4b579ed..4f061d3b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,7 +35,8 @@ def set_version(self): requires = [ ("qt/5.15.2"), ("hobbits-cpython/3.9.1"), - ("fftw/3.3.9") + ("fftw/3.3.9"), + ("pffft/cci.20210511") ] def requirements(self): From 6b7550212c8d18da1d09ffac1885c47b44bf2d1b Mon Sep 17 00:00:00 2001 From: melissascode Date: Thu, 19 Aug 2021 08:57:38 -0400 Subject: [PATCH 08/26] Pushing code to debug the FFT Size error in Spectrogram --- .../analyzers/WidthFramer/widthframerform.cpp | 54 +++++---- .../displays/Spectrogram/spectrogram.cpp | 107 +++++------------- .../displays/Spectrogram/spectrogram.h | 4 +- 3 files changed, 65 insertions(+), 100 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index a40179a9..5a7f7d9e 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include #include "pffft.h" @@ -152,16 +152,15 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b //allocate memory for the input and output arrays //"array of type fftw_complex which is by default double[2]" - //fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); - //fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); + fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); //create set up for PFFFT PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); - //create plans for FFTW - //fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); - //fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); + fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); + fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); //allocate the arrays, or "float buffers," for input, output, and work float *input = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); @@ -169,7 +168,7 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); -/* // prepare and run first FFT + // prepare and run first FFT //is this adding data to the fft_in array? for (int i = 0; i < N; i++) { //real @@ -182,7 +181,8 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b fft_out[i][0] = 0; fft_out[i][1] = 0; } -*/ + + //and run first FFT (with PFFFT) for (int i = 0; i < N; i++){ input[i*2] = 0; //real @@ -194,15 +194,22 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b output[i*2+1]= 0; } + clock_t start = clock(); + //run the first FFT (with FFTW) + fftw_execute(fft_plan1); + clock_t end = clock(); + double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; + //cout << "here is the time (FFTW1): " << cpu_time_used << endl; - //running the first FFT - //fftw_execute(fft_plan1); - - //running the first FFT (with PFFFT) + clock_t start2 = clock(); + //run the first FFT (with PFFFT) pffft_transform_ordered(setup, input, output, work, PFFFT_FORWARD); - - /* - // prepare and run second FFT + clock_t end2 = clock(); + double cpu_time_used2 = ((double) (end2 - start2)) / CLOCKS_PER_SEC; + //cout << "\n" << "here is the time (PFFFT1): " << cpu_time_used2 << endl; + + + // prepare and run second FFT (with FFTW) for (int i = 0; i < N; i++) { double re = fft_out[i][0]; //printf("%f \n", re); @@ -211,9 +218,13 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b fft_in[i][0] = (re * re + im * im) / static_cast(N); fft_in[i][1] = 0.0; } + + clock_t start3 = clock(); //running the second FFT fftw_execute(fft_plan2); - */ + clock_t end3 = clock(); + double cpu_time_used3 = ((double) (end3 - start3)) / CLOCKS_PER_SEC; + cout << "\n" << "here is the time in width framer (FFTW): " << cpu_time_used3 << endl; for (int i = 0; i < N; i++) { float re = output[i*2]; @@ -222,10 +233,12 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b input[i*2+1] = 0.0; } + clock_t start4 = clock(); //perform the second FFT (with PFFFT) pffft_transform_ordered(setup, input, output, work, PFFFT_BACKWARD); - - + clock_t end4 = clock(); + double cpu_time_used4 = ((double) (end4 - start4)) / CLOCKS_PER_SEC; + cout << "\n" << "here is the time in width framer (PFFFT): " << cpu_time_used4 << endl; // get results //results vector size is equal to N / 2 @@ -239,12 +252,13 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b } // clean up - /* + + fftw_destroy_plan(fft_plan1); fftw_destroy_plan(fft_plan2); fftw_free(fft_in); fftw_free(fft_out); - */ + pffft_aligned_free(work); pffft_aligned_free(output); diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 90f8d60a..ba157d64 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -7,7 +7,9 @@ #include "viridis.h" #include "displayresult.h" #include -#include "pffft.h" +#include +#include +using namespace std; Spectrogram::Spectrogram(): @@ -91,6 +93,7 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con } int fftSize = parameters.value("fft_size").toInt(); + //int fftSize = 2064; int fftOverlap = parameters.value("fft_overlap").toInt(); auto sampleFormat = MetadataHelper::sampleFormat(parameters.value("sample_format").toString()); auto dataType = static_cast(parameters.value("data_type").toInt()); @@ -104,15 +107,30 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con return DisplayResult::error(QString("Invalid sample format word size: %1").arg(sampleFormat.wordSize)); } - /*fftw_complex *fftIn = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(fftSize))); - fftw_complex *fftOut = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(fftSize))); - fftw_plan plan = fftw_plan_dft_1d(fftSize, fftIn, fftOut, FFTW_FORWARD, FFTW_ESTIMATE); + + //SIMD size is archetitecure dependent + //read PFFFT documentation for more info + int simd_size = pffft_simd_size(); + cout << "SIMD SIZE FUNCTION:" << simd_size << endl; + + //check if SIMD size is 4 + //if(simd_size == 4){ + //the fftSize needs to be divisble by 16 (for complex FFTs) + //if(fftSize % 16 == 0){ + //PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); + //} + //} + //check if SIMD size is 1 + /* else if(size == 1){ + //the fftSize needs to be divisble by 1 + //any number would be divisble by 1 + } */ //PFFFT set up PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); - //PFFFT allocate memory for input, output, and work arrays or "float buffers" + //PFFFT allocate memory for input, output, and work arrays aka "float buffers" float *input = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); float *output = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); float *work = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); @@ -152,10 +170,6 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con QTime lastTime = QTime::currentTime(); for (int i = 0; i < spectRect.height(); i++) { if (!progress.isNull() && progress->isCancelled()) { - /*fftw_destroy_plan(plan); - fftw_free(fftIn); - fftw_free(fftOut); - */ pffft_aligned_free(work); pffft_aligned_free(output); pffft_aligned_free(input); @@ -166,13 +180,8 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con if (currOffset + fftBits >= container->bits()->sizeInBits()) { break; } - //fillSamples(fftIn, currOffset, container, sampleFormat, fftSize, dataType); - fillSamples(input, currOffset, container, sampleFormat, fftSize, dataType); - /*for (int i = 0; i < fftSize; i++) { - fftIn[i][0] *= hanningWindow[i]; - fftIn[i][1] *= hanningWindow[i]; - }*/ + fillSamples(input, currOffset, container, sampleFormat, fftSize, dataType); for(int i = 0; i < fftSize; i++){ //handle the PFFFT arrays @@ -180,22 +189,21 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con input[i*2+1] *= hanningWindow[i]; } - //fftw_execute_dft(plan, fftIn, fftOut); - //running the first FFT (with PFFFT) + //running the FFT (with PFFFT) + //clock_t start2 = clock(); pffft_transform_ordered(s, input, output, work, PFFFT_FORWARD); + //clock_t end2 = clock(); + //double cpu_time_used2 = ((double) (end2 - start2)) / CLOCKS_PER_SEC; + //cout << "here is the time in spectrogram (PFFFT): " << cpu_time_used2 << endl; QVector spectrum(fftSize/2); if (logarithmicScaling) { for (int n = 0; n < spectrum.size(); n++) { - //spectrum[n] = log(outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1]))) / log(10); - //not sure about the following line spectrum[n] = log(outputFactor * ((output[n*2] * output[n*2]) + (output[i*2+1] * output[i*2+1]))) / log(10); } } else { for (int n = 0; n < spectrum.size(); n++) { - //spectrum[n] = outputFactor * ((fftOut[n][0] * fftOut[n][0]) + (fftOut[n][1] * fftOut[n][1])); - //not sure about the following line spectrum[n] = outputFactor * ((output[n*2] * output[n*2]) + (output[n*2+1] * output[n*2+1])); } } @@ -218,10 +226,6 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con } } - /*fftw_destroy_plan(plan); - fftw_free(fftIn); - fftw_free(fftOut); - */ pffft_aligned_free(work); pffft_aligned_free(output); pffft_aligned_free(input); @@ -507,9 +511,6 @@ QString Spectrogram::timeString(qint64 sample, double sampleRate) } } - -//COME TO THIS FUNCTION! FFTW STUFF NEEDS TO BE REPLACED WITH PFFFT -/*void Spectrogram::fillSamples(fftw_complex* buffer*/ void Spectrogram::fillSamples(float* buffer, qint64 offset, QSharedPointer bitContainer, @@ -530,16 +531,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(fBuffer[i*2]); - //buffer[i][1] = double(fBuffer[i*2 + 1]); buffer[i*2] = double(fBuffer[i*2]); buffer[i*2+1] = double(fBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(fBuffer[i]); - //buffer[i][1] = 0.0; buffer[i*2] = double(fBuffer[i]); buffer[i*2+1] = 0.0; } @@ -552,16 +549,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]); - //buffer[i][1] = double(sBuffer[i*2 + 1]); buffer[i*2] = double(sBuffer[i*2]); buffer[i*2+1] = double(sBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]); - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]); buffer[i*2+1] = 0.0; } @@ -574,16 +567,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -596,16 +585,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -618,16 +603,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -640,16 +621,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -662,16 +639,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -684,16 +657,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -706,16 +675,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -728,16 +693,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -750,16 +711,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } @@ -772,16 +729,12 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - //buffer[i][0] = double(sBuffer[i*2]) / weight; - //buffer[i][1] = double(sBuffer[i*2 + 1]) / weight; buffer[i*2] = double(sBuffer[i*2]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - //buffer[i][0] = double(sBuffer[i]) / weight; - //buffer[i][1] = 0.0; buffer[i*2] = double(sBuffer[i]) / weight; buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; } @@ -790,8 +743,6 @@ void Spectrogram::fillSamples(float* buffer, } for (qint64 i = samples; i < fftSize; i++) { - //buffer[i][0] = 0.0; - //buffer[i][1] = 0.0; buffer[i*2] = 0.0; buffer[i*2+1] = 0.0; } diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.h b/src/hobbits-plugins/displays/Spectrogram/spectrogram.h index 0126bc60..a7e7b16f 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.h +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.h @@ -3,7 +3,7 @@ #include "displayinterface.h" #include "spectrogramcontrols.h" -#include "fftw3.h" +#include "pffft.h" #include "metadatahelper.h" class Spectrogram : public QObject, DisplayInterface @@ -44,7 +44,7 @@ class Spectrogram : public QObject, DisplayInterface QSharedPointer bitContainer, const MetadataHelper::SampleFormat &sampleFormat, int fftSize, - SpectrogramControls::DataType dataType); + SpectrogramControls::DataType dataType); void setSpectrums(QList> spectrums); From 6a8dbff0c9330b1e5dddb4745c8ed9fd514c28c6 Mon Sep 17 00:00:00 2001 From: melissascode Date: Thu, 19 Aug 2021 10:23:37 -0400 Subject: [PATCH 09/26] Removed some code that was commented out, still debugging FFT Size error --- .../displays/Spectrogram/spectrogram.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index ba157d64..7674d24c 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -109,24 +109,13 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con //SIMD size is archetitecure dependent - //read PFFFT documentation for more info int simd_size = pffft_simd_size(); cout << "SIMD SIZE FUNCTION:" << simd_size << endl; - //check if SIMD size is 4 - //if(simd_size == 4){ - //the fftSize needs to be divisble by 16 (for complex FFTs) - //if(fftSize % 16 == 0){ - //PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); - //} - //} - //check if SIMD size is 1 - /* else if(size == 1){ - //the fftSize needs to be divisble by 1 - //any number would be divisble by 1 - } - */ - + //Note: + //FFT size needs to be of the form specified in the documentation + //need to add logic to this file to ensure that the correct FFT size is used + //PFFFT set up PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); From 109b0b3b1e7068e2af97f160fb1bf8c7c2512636 Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 20 Aug 2021 18:06:00 -0400 Subject: [PATCH 10/26] Added logic to make sure that FFT size is divisble by 16. If the FFT size given is not divisible by 16, the FFT size will be increased to the next number divisble by 16. --- .../displays/Spectrogram/spectrogram.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 7674d24c..23255d54 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -117,7 +117,18 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con //need to add logic to this file to ensure that the correct FFT size is used //PFFFT set up + //check if fftSize is 16 + //according to PFFFT documenation, complex FFTs must have an FFT Size that is divisble by 16 + //make fftSize the next number divisble by 16 + + //make sure its greater than 32?? + if(fftSize % 16 != 0){ + fftSize = (16 - (fftSize % 16)) + fftSize; + cout << "Changed FFT Size to this value: " << fftSize << endl; + } PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); + + //PFFFT allocate memory for input, output, and work arrays aka "float buffers" float *input = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); From 7dde012cd57f5a2816172089968a208c69e42770 Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 20 Aug 2021 18:27:02 -0400 Subject: [PATCH 11/26] Added code to make sure FFT size is greater than 32 --- src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 23255d54..53a5b8a3 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -121,14 +121,11 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con //according to PFFFT documenation, complex FFTs must have an FFT Size that is divisble by 16 //make fftSize the next number divisble by 16 - //make sure its greater than 32?? - if(fftSize % 16 != 0){ + if(fftSize % 16 != 0 || fftSize < 32){ fftSize = (16 - (fftSize % 16)) + fftSize; cout << "Changed FFT Size to this value: " << fftSize << endl; } PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); - - //PFFFT allocate memory for input, output, and work arrays aka "float buffers" float *input = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); From 8854c0743601cf93673fab08d1ad595e78b44d75 Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 20 Aug 2021 18:56:31 -0400 Subject: [PATCH 12/26] Removed FFTW code from Width Framer --- .../analyzers/WidthFramer/widthframerform.cpp | 75 ++----------------- .../displays/Spectrogram/spectrogram.cpp | 4 +- 2 files changed, 10 insertions(+), 69 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 5a7f7d9e..c3b2cdb2 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -145,45 +145,18 @@ void WidthFramerForm::widthSelected(QModelIndex index) QVector WidthFramerForm::autocorrelate(QSharedPointer bits) { - //replace FFTW library - //left shift int N = 1 << 19; - //allocate memory for the input and output arrays - //"array of type fftw_complex which is by default double[2]" - fftw_complex *fft_in = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); - fftw_complex *fft_out = reinterpret_cast(fftw_malloc(sizeof(fftw_complex) * unsigned(N))); - //create set up for PFFFT PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); - //create plans for FFTW - fftw_plan fft_plan1 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE); - fftw_plan fft_plan2 = fftw_plan_dft_1d(N, fft_in, fft_out, FFTW_BACKWARD, FFTW_ESTIMATE); - //allocate the arrays, or "float buffers," for input, output, and work float *input = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *output = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); - - // prepare and run first FFT - //is this adding data to the fft_in array? - for (int i = 0; i < N; i++) { - //real - fft_in[i][0] = 0; - //imaginary - fft_in[i][1] = 0; - if (i < bits->sizeInBits()) { - fft_in[i][0] = bits->at(i) ? 1 : -1; - } - fft_out[i][0] = 0; - fft_out[i][1] = 0; - } - - - //and run first FFT (with PFFFT) + //prepare and run first FFT (with PFFFT) for (int i = 0; i < N; i++){ input[i*2] = 0; //real input[i*2+1] = 0; //imaginary @@ -194,38 +167,15 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b output[i*2+1]= 0; } - clock_t start = clock(); - //run the first FFT (with FFTW) - fftw_execute(fft_plan1); - clock_t end = clock(); - double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; - //cout << "here is the time (FFTW1): " << cpu_time_used << endl; - - clock_t start2 = clock(); + //clock_t start2 = clock(); //run the first FFT (with PFFFT) pffft_transform_ordered(setup, input, output, work, PFFFT_FORWARD); - clock_t end2 = clock(); + /*clock_t end2 = clock(); double cpu_time_used2 = ((double) (end2 - start2)) / CLOCKS_PER_SEC; //cout << "\n" << "here is the time (PFFFT1): " << cpu_time_used2 << endl; + */ - - // prepare and run second FFT (with FFTW) - for (int i = 0; i < N; i++) { - double re = fft_out[i][0]; - //printf("%f \n", re); - double im = fft_out[i][1]; - //printf("%f \n", im); - fft_in[i][0] = (re * re + im * im) / static_cast(N); - fft_in[i][1] = 0.0; - } - - clock_t start3 = clock(); - //running the second FFT - fftw_execute(fft_plan2); - clock_t end3 = clock(); - double cpu_time_used3 = ((double) (end3 - start3)) / CLOCKS_PER_SEC; - cout << "\n" << "here is the time in width framer (FFTW): " << cpu_time_used3 << endl; - + //prepare and run second FFT for (int i = 0; i < N; i++) { float re = output[i*2]; float im = output[i*2+1]; @@ -233,17 +183,16 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b input[i*2+1] = 0.0; } - clock_t start4 = clock(); + //clock_t start4 = clock(); //perform the second FFT (with PFFFT) pffft_transform_ordered(setup, input, output, work, PFFFT_BACKWARD); - clock_t end4 = clock(); + /*clock_t end4 = clock(); double cpu_time_used4 = ((double) (end4 - start4)) / CLOCKS_PER_SEC; cout << "\n" << "here is the time in width framer (PFFFT): " << cpu_time_used4 << endl; + */ // get results - //results vector size is equal to N / 2 QVector results(N / 2); - //insert at first index results.insert(0, QPointF(0, 0)); for (int i = 1; i < N / 2; i++) { double re = qAbs(double(output[i*2] / double(N))); @@ -252,14 +201,6 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b } // clean up - - - fftw_destroy_plan(fft_plan1); - fftw_destroy_plan(fft_plan2); - fftw_free(fft_in); - fftw_free(fft_out); - - pffft_aligned_free(work); pffft_aligned_free(output); pffft_aligned_free(input); diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 53a5b8a3..d626c8af 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -116,15 +116,15 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con //FFT size needs to be of the form specified in the documentation //need to add logic to this file to ensure that the correct FFT size is used - //PFFFT set up //check if fftSize is 16 //according to PFFFT documenation, complex FFTs must have an FFT Size that is divisble by 16 //make fftSize the next number divisble by 16 - if(fftSize % 16 != 0 || fftSize < 32){ fftSize = (16 - (fftSize % 16)) + fftSize; cout << "Changed FFT Size to this value: " << fftSize << endl; } + + //PFFFT set up PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); //PFFFT allocate memory for input, output, and work arrays aka "float buffers" From 1a4af2d876eee8c3dfd0ce3dabb18868fe2c0ec8 Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 27 Aug 2021 16:36:24 -0400 Subject: [PATCH 13/26] Updated the Spectrogram to have a QComboBox instead of a QSpinBox for gathering the FFT Size from the user. --- .../displays/Spectrogram/spectrogram.cpp | 34 ++++++------------- .../Spectrogram/spectrogramcontrols.cpp | 18 ++++++++-- .../Spectrogram/spectrogramcontrols.ui | 15 +------- 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index d626c8af..1f6762d6 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -93,7 +93,6 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con } int fftSize = parameters.value("fft_size").toInt(); - //int fftSize = 2064; int fftOverlap = parameters.value("fft_overlap").toInt(); auto sampleFormat = MetadataHelper::sampleFormat(parameters.value("sample_format").toString()); auto dataType = static_cast(parameters.value("data_type").toInt()); @@ -107,27 +106,20 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con return DisplayResult::error(QString("Invalid sample format word size: %1").arg(sampleFormat.wordSize)); } + //check whether the fftSize is divisible by 32 + if(fftSize % 32 != 0){ + return DisplayResult::error(QString("FFT Size needs to be divisible by 32 - %1 is invalid").arg(fftSize)); + } - //SIMD size is archetitecure dependent - int simd_size = pffft_simd_size(); - cout << "SIMD SIZE FUNCTION:" << simd_size << endl; - - //Note: - //FFT size needs to be of the form specified in the documentation - //need to add logic to this file to ensure that the correct FFT size is used + //set up for PFFFT + PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); - //check if fftSize is 16 - //according to PFFFT documenation, complex FFTs must have an FFT Size that is divisble by 16 - //make fftSize the next number divisble by 16 - if(fftSize % 16 != 0 || fftSize < 32){ - fftSize = (16 - (fftSize % 16)) + fftSize; - cout << "Changed FFT Size to this value: " << fftSize << endl; + //check whether the setup pointer is null + if(!s){ + return DisplayResult::error(QString("PFFFT failed to initialize with FFT Size %1").arg(fftSize)); } - - //PFFFT set up - PFFFT_Setup *s = pffft_new_setup(fftSize, PFFFT_COMPLEX); - //PFFFT allocate memory for input, output, and work arrays aka "float buffers" + //allocate memory for input, output, and work arrays aka "float buffers" float *input = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); float *output = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); float *work = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); @@ -186,12 +178,8 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con input[i*2+1] *= hanningWindow[i]; } - //running the FFT (with PFFFT) - //clock_t start2 = clock(); + //execute the FFT with PFFFT pffft_transform_ordered(s, input, output, work, PFFFT_FORWARD); - //clock_t end2 = clock(); - //double cpu_time_used2 = ((double) (end2 - start2)) / CLOCKS_PER_SEC; - //cout << "here is the time in spectrogram (PFFFT): " << cpu_time_used2 << endl; QVector spectrum(fftSize/2); if (logarithmicScaling) { diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp index 08fceff9..8e1a1dfe 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp @@ -32,7 +32,21 @@ SpectrogramControls::SpectrogramControls(QSharedPointer deleg m_paramHelper->addComboBoxParameter("data_type", ui->cb_dataType); m_paramHelper->addSliderIntParameter("sensitivity", ui->hs_sensitivity); - m_paramHelper->addSpinBoxIntParameter("fft_size", ui->sb_fftSize); + + ui->cb_fftSize->addItem("32", (pow(2.0, 5.0))); + ui->cb_fftSize->addItem("64", (pow(2.0, 6.0))); + ui->cb_fftSize->addItem("128", (pow(2.0, 7.0))); + ui->cb_fftSize->addItem("256", (pow(2.0, 8.0))); + ui->cb_fftSize->addItem("512", (pow(2.0, 9.0))); + ui->cb_fftSize->addItem("1,024", (pow(2.0, 10.0))); + ui->cb_fftSize->addItem("2,048", (pow(2.0, 11.0))); + ui->cb_fftSize->addItem("4,096", (pow(2.0, 12.0))); + ui->cb_fftSize->addItem("8,192", (pow(2.0, 13.0))); + ui->cb_fftSize->addItem("16,384", (pow(2.0, 14.0))); + ui->cb_fftSize->addItem("32,768", (pow(2.0, 15.0))); + ui->cb_fftSize->addItem("65,536", (pow(2.0, 16.0))); + m_paramHelper->addComboBoxParameter("fft_size", ui->cb_fftSize); + m_paramHelper->addSpinBoxIntParameter("fft_overlap", ui->sb_overlap); m_paramHelper->addCheckBoxBoolParameter("show_headers", ui->ck_showHeaders); @@ -40,7 +54,6 @@ SpectrogramControls::SpectrogramControls(QSharedPointer deleg m_paramHelper->addCheckBoxBoolParameter("logarithmic_scaling", ui->ck_logarithmic); connect(ui->hs_sensitivity, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); - connect(ui->sb_fftSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); connect(ui->sb_overlap, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); connect(ui->ck_showHeaders, SIGNAL(toggled(bool)), this, SIGNAL(changed())); connect(ui->ck_hoverSlices, SIGNAL(toggled(bool)), this, SIGNAL(changed())); @@ -48,6 +61,7 @@ SpectrogramControls::SpectrogramControls(QSharedPointer deleg connect(ui->cb_sampleFormat, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed())); connect(ui->cb_dataType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed())); + connect(ui->cb_fftSize, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed())); connect(ui->sb_sampleRate, SIGNAL(valueChanged(double)), this, SIGNAL(changed())); connect(ui->cb_rateUnits, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed())); diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.ui b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.ui index d4947faa..0dda230b 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.ui +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.ui @@ -70,20 +70,7 @@ - - - - - - 32 - - - 131072 - - - 2048 - - + From 5897bfcf184368762a7d567db08160a34b5bdf1a Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 27 Aug 2021 16:43:27 -0400 Subject: [PATCH 14/26] Removed the include for FFTW and cleaned up the comments. --- .../analyzers/WidthFramer/widthframerform.cpp | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index c3b2cdb2..3911cddd 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "pffft.h" @@ -156,7 +155,7 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b float *output = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); - //prepare and run first FFT (with PFFFT) + //prepare first FFT for (int i = 0; i < N; i++){ input[i*2] = 0; //real input[i*2+1] = 0; //imaginary @@ -167,15 +166,11 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b output[i*2+1]= 0; } - //clock_t start2 = clock(); - //run the first FFT (with PFFFT) + //run first FFT pffft_transform_ordered(setup, input, output, work, PFFFT_FORWARD); - /*clock_t end2 = clock(); - double cpu_time_used2 = ((double) (end2 - start2)) / CLOCKS_PER_SEC; - //cout << "\n" << "here is the time (PFFFT1): " << cpu_time_used2 << endl; - */ + - //prepare and run second FFT + //prepare second FFT for (int i = 0; i < N; i++) { float re = output[i*2]; float im = output[i*2+1]; @@ -183,13 +178,9 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b input[i*2+1] = 0.0; } - //clock_t start4 = clock(); - //perform the second FFT (with PFFFT) + //run second FFT pffft_transform_ordered(setup, input, output, work, PFFFT_BACKWARD); - /*clock_t end4 = clock(); - double cpu_time_used4 = ((double) (end4 - start4)) / CLOCKS_PER_SEC; - cout << "\n" << "here is the time in width framer (PFFFT): " << cpu_time_used4 << endl; - */ + // get results QVector results(N / 2); From 7c535287dc1a6cd1b899bcffcc0f079795034058 Mon Sep 17 00:00:00 2001 From: melissascode Date: Fri, 27 Aug 2021 16:43:57 -0400 Subject: [PATCH 15/26] Removed FFTW from the CMakeList files. --- src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt | 1 - src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt index 279f501f..3063d4df 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt +++ b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt @@ -2,7 +2,6 @@ pluginInDir("${pluginType}" "WidthFramer" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) - target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE CONAN_PKG::fftw) target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE CONAN_PKG::pffft) else() if(WIN32) diff --git a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt index 3164a801..e381b304 100644 --- a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt +++ b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt @@ -3,7 +3,6 @@ pluginInDir("${pluginType}" "Spectrogram" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) - target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE CONAN_PKG::fftw) target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE CONAN_PKG::pffft) else() if(WIN32) From c76554a929498291d70aa4164ac7ba50a178bb18 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 29 Aug 2021 15:43:43 -0400 Subject: [PATCH 16/26] Removed fftw --- conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 4f061d3b..77880d54 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,7 +35,6 @@ def set_version(self): requires = [ ("qt/5.15.2"), ("hobbits-cpython/3.9.1"), - ("fftw/3.3.9"), ("pffft/cci.20210511") ] From 7e849179bca9cb007f3df8dbf725a27c412f0c90 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 29 Aug 2021 15:44:48 -0400 Subject: [PATCH 17/26] Updated according to the changes requested by Adam in my recent pull request. --- .../analyzers/WidthFramer/widthframerform.cpp | 33 +++++--- .../displays/Spectrogram/spectrogram.cpp | 76 +++++++++---------- .../Spectrogram/spectrogramcontrols.cpp | 23 +++--- 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 3911cddd..e8bd2030 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -4,13 +4,8 @@ #include #include #include -#include #include "pffft.h" - -#include -using namespace std; - WidthFramerForm::WidthFramerForm(QSharedPointer delegate) : ui(new Ui::WidthFramerForm()), m_delegate(delegate), @@ -144,21 +139,40 @@ void WidthFramerForm::widthSelected(QModelIndex index) QVector WidthFramerForm::autocorrelate(QSharedPointer bits) { - //left shift int N = 1 << 19; //create set up for PFFFT PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); + + if(!setup){ + //return an empty vector + QVector badSetup(N / 2); + return badSetup; + } //allocate the arrays, or "float buffers," for input, output, and work float *input = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *output = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); + //if any float buffers are null return an empty vector + if(!input){ + QVector nullInput(N / 2); + return nullInput; + } + if(!output){ + QVector nullOutput(N / 2); + return nullOutput; + } + if(!work){ + QVector nullWork(N / 2); + return nullWork; + } + //prepare first FFT for (int i = 0; i < N; i++){ - input[i*2] = 0; //real - input[i*2+1] = 0; //imaginary + input[i*2] = 0; + input[i*2+1] = 0; if (i < bits->sizeInBits()) { input[i*2] = bits->at(i) ? 1 : -1; } @@ -186,8 +200,7 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b QVector results(N / 2); results.insert(0, QPointF(0, 0)); for (int i = 1; i < N / 2; i++) { - double re = qAbs(double(output[i*2] / double(N))); - //store in results vector + float re = qAbs(float(output[i*2] / float(N))); results[i] = QPointF(i, re); } diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index 1f6762d6..aa4f9e8e 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -184,7 +184,7 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con QVector spectrum(fftSize/2); if (logarithmicScaling) { for (int n = 0; n < spectrum.size(); n++) { - spectrum[n] = log(outputFactor * ((output[n*2] * output[n*2]) + (output[i*2+1] * output[i*2+1]))) / log(10); + spectrum[n] = log(outputFactor * ((output[n*2] * output[n*2]) + (output[n*2+1] * output[n*2+1]))) / log(10); } } else { @@ -516,13 +516,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(fBuffer[i*2]); - buffer[i*2+1] = double(fBuffer[i*2 + 1]); + buffer[i*2] = float(fBuffer[i*2]); + buffer[i*2+1] = float(fBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(fBuffer[i]); + buffer[i*2] = float(fBuffer[i]); buffer[i*2+1] = 0.0; } } @@ -534,13 +534,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]); - buffer[i*2+1] = double(sBuffer[i*2 + 1]); + buffer[i*2] = float(sBuffer[i*2]); + buffer[i*2+1] = float(sBuffer[i*2 + 1]); } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]); + buffer[i*2] = float(sBuffer[i]); buffer[i*2+1] = 0.0; } } @@ -552,13 +552,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -570,13 +570,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -588,13 +588,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -606,13 +606,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -624,13 +624,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -642,13 +642,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -660,13 +660,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -678,13 +678,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -696,13 +696,13 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; buffer[i*2+1] = 0.0; } } @@ -714,14 +714,14 @@ void Spectrogram::fillSamples(float* buffer, if (dataType == SpectrogramControls::RealComplexInterleaved) { for (int i = 0; i < samples/2; i++) { - buffer[i*2] = double(sBuffer[i*2]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i*2]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } else { for (int i = 0; i < samples; i++) { - buffer[i*2] = double(sBuffer[i]) / weight; - buffer[i*2+1] = double(sBuffer[i*2 + 1]) / weight; + buffer[i*2] = float(sBuffer[i]) / weight; + buffer[i*2+1] = float(sBuffer[i*2 + 1]) / weight; } } delete[] sBuffer; diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp index 8e1a1dfe..4986b28c 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogramcontrols.cpp @@ -2,6 +2,7 @@ #include "ui_spectrogramcontrols.h" #include "metadatahelper.h" + SpectrogramControls::SpectrogramControls(QSharedPointer delegate) : ui(new Ui::SpectrogramControls()), m_paramHelper(new ParameterHelper(delegate)) @@ -33,18 +34,16 @@ SpectrogramControls::SpectrogramControls(QSharedPointer deleg m_paramHelper->addSliderIntParameter("sensitivity", ui->hs_sensitivity); - ui->cb_fftSize->addItem("32", (pow(2.0, 5.0))); - ui->cb_fftSize->addItem("64", (pow(2.0, 6.0))); - ui->cb_fftSize->addItem("128", (pow(2.0, 7.0))); - ui->cb_fftSize->addItem("256", (pow(2.0, 8.0))); - ui->cb_fftSize->addItem("512", (pow(2.0, 9.0))); - ui->cb_fftSize->addItem("1,024", (pow(2.0, 10.0))); - ui->cb_fftSize->addItem("2,048", (pow(2.0, 11.0))); - ui->cb_fftSize->addItem("4,096", (pow(2.0, 12.0))); - ui->cb_fftSize->addItem("8,192", (pow(2.0, 13.0))); - ui->cb_fftSize->addItem("16,384", (pow(2.0, 14.0))); - ui->cb_fftSize->addItem("32,768", (pow(2.0, 15.0))); - ui->cb_fftSize->addItem("65,536", (pow(2.0, 16.0))); + ui->cb_fftSize->addItem("32", 1 << 5); + ui->cb_fftSize->addItem("64", 1 << 6); + ui->cb_fftSize->addItem("128", 1 << 7); + ui->cb_fftSize->addItem("256", 1 << 8); + ui->cb_fftSize->addItem("512", 1 << 9); + ui->cb_fftSize->addItem("1,024", 1 << 10); + ui->cb_fftSize->addItem("2,048", 1 << 11); + ui->cb_fftSize->addItem("4,096", 1 << 12); + ui->cb_fftSize->addItem("8,192", 1 << 13); + ui->cb_fftSize->addItem("16,384", 1 << 14); m_paramHelper->addComboBoxParameter("fft_size", ui->cb_fftSize); m_paramHelper->addSpinBoxIntParameter("fft_overlap", ui->sb_overlap); From 81a3da824b0b00cc57adb56792f0e06423c90b7d Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 5 Sep 2021 22:08:22 -0400 Subject: [PATCH 18/26] Refactored according to changes requested on pull request. --- .../analyzers/WidthFramer/widthframerform.cpp | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index e8bd2030..0daa9d59 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -145,9 +145,7 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); if(!setup){ - //return an empty vector - QVector badSetup(N / 2); - return badSetup; + return QVector(); } //allocate the arrays, or "float buffers," for input, output, and work @@ -155,20 +153,10 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b float *output = (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); float *work= (float*)pffft_aligned_malloc(N * 2 * sizeof(float)); - //if any float buffers are null return an empty vector - if(!input){ - QVector nullInput(N / 2); - return nullInput; + if(!input || !output || !work){ + return QVector(); } - if(!output){ - QVector nullOutput(N / 2); - return nullOutput; - } - if(!work){ - QVector nullWork(N / 2); - return nullWork; - } - + //prepare first FFT for (int i = 0; i < N; i++){ input[i*2] = 0; From dafd1bddbdbe6eb779cd2fef0634bf1db223da13 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 5 Sep 2021 22:16:37 -0400 Subject: [PATCH 19/26] Refactored according to changes requested in the pull request. --- .../analyzers/WidthFramer/widthframerform.cpp | 1 + src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp index 0daa9d59..2e33d5ce 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp +++ b/src/hobbits-plugins/analyzers/WidthFramer/widthframerform.cpp @@ -145,6 +145,7 @@ QVector WidthFramerForm::autocorrelate(QSharedPointer b PFFFT_Setup *setup = pffft_new_setup(N, PFFFT_COMPLEX); if(!setup){ + //return empty vector return QVector(); } diff --git a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp index aa4f9e8e..8eaf4360 100644 --- a/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp +++ b/src/hobbits-plugins/displays/Spectrogram/spectrogram.cpp @@ -7,9 +7,6 @@ #include "viridis.h" #include "displayresult.h" #include -#include -#include -using namespace std; Spectrogram::Spectrogram(): @@ -124,6 +121,10 @@ QSharedPointer Spectrogram::renderDisplay(QSize viewportSize, con float *output = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); float *work = (float*)pffft_aligned_malloc(fftSize * 2 * sizeof(float)); + if(!input || !output || !work){ + return DisplayResult::error(QString("Failed to allocate float buffers.")); + } + QVector hanningWindow(fftSize); for (int i = 0; i < fftSize; i++) { hanningWindow[i] = 0.5*(1.0-cos(2.0*M_PI*i/double(fftSize-1.0))); From ad90f0d7bc7ff4aea2209c0a72b0c60c0f1d454f Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 5 Sep 2021 22:26:22 -0400 Subject: [PATCH 20/26] Removed CONAN_PKG::fftw and removed include for fftw from hobbits-gui/main.cpp and hobbits-runner/main.cpp --- src/hobbits-gui/CMakeLists.txt | 2 +- src/hobbits-gui/main.cpp | 4 ++-- src/hobbits-runner/CMakeLists.txt | 2 +- src/hobbits-runner/main.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hobbits-gui/CMakeLists.txt b/src/hobbits-gui/CMakeLists.txt index c0893692..66e4859e 100644 --- a/src/hobbits-gui/CMakeLists.txt +++ b/src/hobbits-gui/CMakeLists.txt @@ -17,7 +17,7 @@ file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DI if (BUILDING_WITH_CONAN) - set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::fftw) + set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::pffft) else() set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets) if(WIN32) diff --git a/src/hobbits-gui/main.cpp b/src/hobbits-gui/main.cpp index e518c2f5..ea36410e 100644 --- a/src/hobbits-gui/main.cpp +++ b/src/hobbits-gui/main.cpp @@ -10,12 +10,12 @@ #include #endif -#include "fftw3.h" +//#include "pffft.h" int main(int argc, char *argv[]) { // See http://www.fftw.org/fftw3_doc/Thread-safety.html - fftw_make_planner_thread_safe(); + // fftw_make_planner_thread_safe(); QApplication a(argc, argv); diff --git a/src/hobbits-runner/CMakeLists.txt b/src/hobbits-runner/CMakeLists.txt index f4256856..a0c1b0c8 100644 --- a/src/hobbits-runner/CMakeLists.txt +++ b/src/hobbits-runner/CMakeLists.txt @@ -17,7 +17,7 @@ file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DI add_executable("hobbits-runner" "${SRCFILES}" "${HDRFILES}" "${RCFILES}") if (BUILDING_WITH_CONAN) - set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::fftw) + set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::pffft) else() set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets) if(WIN32) diff --git a/src/hobbits-runner/main.cpp b/src/hobbits-runner/main.cpp index ea095837..d0aed55c 100644 --- a/src/hobbits-runner/main.cpp +++ b/src/hobbits-runner/main.cpp @@ -18,12 +18,12 @@ #include "hobbitspythonconfig.h" #include "pythonpluginconfig.h" -#include "fftw3.h" +//#include "pffft.h" int main(int argc, char *argv[]) { // See http://www.fftw.org/fftw3_doc/Thread-safety.html - fftw_make_planner_thread_safe(); + // fftw_make_planner_thread_safe(); QGuiApplication a(argc, argv); From a11154bdf1296112b614c4f759684cb5f4116094 Mon Sep 17 00:00:00 2001 From: melissascode Date: Thu, 7 Oct 2021 11:12:29 -0400 Subject: [PATCH 21/26] Trying to resolve merge conflict w/ conanfile.py and making changes from pull request. --- conanfile.py | 2 +- src/hobbits-gui/main.cpp | 5 ----- src/hobbits-runner/main.cpp | 5 ----- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/conanfile.py b/conanfile.py index 5f3b1d19..299e3159 100644 --- a/conanfile.py +++ b/conanfile.py @@ -34,7 +34,7 @@ def set_version(self): requires = [ ("qt/5.15.2"), - ("hobbits-cpython/3.9.1"), + ("hobbits-cpython/3.9.7"), ("pffft/cci.20210511"), ("libusb/1.0.24") ] diff --git a/src/hobbits-gui/main.cpp b/src/hobbits-gui/main.cpp index ea36410e..35f82ba9 100644 --- a/src/hobbits-gui/main.cpp +++ b/src/hobbits-gui/main.cpp @@ -10,13 +10,8 @@ #include #endif -//#include "pffft.h" - int main(int argc, char *argv[]) { - // See http://www.fftw.org/fftw3_doc/Thread-safety.html - // fftw_make_planner_thread_safe(); - QApplication a(argc, argv); HobbitsStyle::applyStyle(a); diff --git a/src/hobbits-runner/main.cpp b/src/hobbits-runner/main.cpp index d0aed55c..31817034 100644 --- a/src/hobbits-runner/main.cpp +++ b/src/hobbits-runner/main.cpp @@ -18,13 +18,8 @@ #include "hobbitspythonconfig.h" #include "pythonpluginconfig.h" -//#include "pffft.h" - int main(int argc, char *argv[]) { - // See http://www.fftw.org/fftw3_doc/Thread-safety.html - // fftw_make_planner_thread_safe(); - QGuiApplication a(argc, argv); QGuiApplication::setApplicationName("Hobbits Runner"); From 5be8c79b653f7c19ca1ae180fa9ba7d37c8fc262 Mon Sep 17 00:00:00 2001 From: melissascode Date: Thu, 7 Oct 2021 11:40:22 -0400 Subject: [PATCH 22/26] Merging from Mahlet-Inc-develop --- .releaserc.json | 23 +++++++++-- azure-pipelines.yml | 39 +++++++++++++++++-- ci/linux.yml | 3 -- ci/mac.yml | 11 ++++-- ci/windows.yml | 9 ++++- conanfile.py | 4 ++ .../analyzers/KaitaiStruct/scripts/runner.py | 2 +- 7 files changed, 74 insertions(+), 17 deletions(-) diff --git a/.releaserc.json b/.releaserc.json index 9922285f..203bed82 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -35,14 +35,29 @@ "name": "hobbits-${nextRelease.version}-gcc7.tgz" }, { - "path": "hobbits/windows_release/windows_release.zip", + "path": "hobbits/ubuntu20_gcc9_release/ubuntu20_gcc9_release.tar.gz", + "label": "Hobbits (64-bit Ubuntu 20.04 GCC 9)", + "name": "hobbits-${nextRelease.version}-gcc9.tgz" + }, + { + "path": "hobbits/win_2016_release/win_2016_release.zip", "label": "Hobbits (64-bit Windows 2016 msvc2017)", - "name": "hobbits-${nextRelease.version}-win.zip" + "name": "hobbits-${nextRelease.version}-win2016.zip" + }, + { + "path": "hobbits/win_2019_release/win_2019_release.zip", + "label": "Hobbits (64-bit Windows 2019)", + "name": "hobbits-${nextRelease.version}-win2019.zip" }, { - "path": "hobbits/mac_release/mac_release.tar.gz", + "path": "hobbits/mac_1014_release/mac_1014_release.tar.gz", "label": "Hobbits (64-bit Mac OSX 10.14)", - "name": "hobbits-${nextRelease.version}-mac.tgz" + "name": "hobbits-${nextRelease.version}-mac1014.tgz" + }, + { + "path": "hobbits/mac_11_release/mac_11_release.tar.gz", + "label": "Hobbits (64-bit Mac OSX 11)", + "name": "hobbits-${nextRelease.version}-mac11.tgz" } ] } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ff49a64e..7d5426ef 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,7 +8,7 @@ pr: - develop jobs: -- job: UbuntuLinuxGCC7 +- job: UbuntuLinux18GCC7 pool: vmImage: 'ubuntu-18.04' steps: @@ -16,7 +16,16 @@ jobs: - template: ci/linux.yml parameters: artifactName: ubuntu18_gcc7_release - pythonArtifact: python_ubuntu_1804 + +- job: UbuntuLinux20GCC9 + pool: + vmImage: 'ubuntu-20.04' + steps: + - template: ci/ubuntu-setup.yml + - template: ci/linux.yml + parameters: + artifactName: ubuntu20_gcc9_release + - job: CentOS74LinuxGCC48 pool: vmImage: 'ubuntu-18.04' @@ -26,13 +35,35 @@ jobs: parameters: artifactName: centos7_gcc48_release pythonArtifact: python_centos_74 -- job: Windows + +- job: Windows2019 + pool: + vmImage: 'windows-2019' + steps: + - template: ci/windows.yml + parameters: + artifactName: win_2019_release + +- job: Windows2016vs2017 pool: vmImage: 'vs2017-win2016' steps: - template: ci/windows.yml -- job: Mac + parameters: + artifactName: win_2016_release + +- job: Mac1014 pool: vmImage: 'macOS-10.14' steps: - template: ci/mac.yml + parameters: + artifactName: mac_1014_release + +- job: Mac11 + pool: + vmImage: 'macOS-11' + steps: + - template: ci/mac.yml + parameters: + artifactName: mac_11_release diff --git a/ci/linux.yml b/ci/linux.yml index d791ccf7..6c3c148a 100644 --- a/ci/linux.yml +++ b/ci/linux.yml @@ -2,9 +2,6 @@ parameters: - name: artifactName type: string default: linux_release - - name: pythonArtifact - type: string - default: python_linux steps: - checkout: self diff --git a/ci/mac.yml b/ci/mac.yml index 8e751a29..6c69d8c8 100644 --- a/ci/mac.yml +++ b/ci/mac.yml @@ -1,3 +1,8 @@ +parameters: + - name: artifactName + type: string + default: mac_release + steps: - checkout: self persistCredentials: true @@ -58,12 +63,12 @@ steps: displayName: 'Run conan package' - bash: | - tar -czf ../mac_release.tar.gz . - cp ../mac_release.tar.gz $(Build.ArtifactStagingDirectory) + tar -czf ../${{ parameters.artifactName }}.tar.gz . + cp ../${{ parameters.artifactName }}.tar.gz $(Build.ArtifactStagingDirectory) workingDirectory: $(Build.SourcesDirectory)/build/package displayName: 'Collect and zip package files' - task: PublishBuildArtifacts@1 inputs: pathToPublish: $(Build.ArtifactStagingDirectory) - artifactName: mac_release + artifactName: ${{ parameters.artifactName }} diff --git a/ci/windows.yml b/ci/windows.yml index 0d5105b6..c381dcfd 100644 --- a/ci/windows.yml +++ b/ci/windows.yml @@ -1,3 +1,8 @@ +parameters: + - name: artifactName + type: string + default: win_release + steps: - checkout: self persistCredentials: true @@ -49,10 +54,10 @@ steps: inputs: rootFolderOrFile: $(Build.SourcesDirectory)/build/package includeRootFolder: false - archiveFile: $(Build.ArtifactStagingDirectory)/windows_release.zip + archiveFile: $(Build.ArtifactStagingDirectory)/${{ parameters.artifactName }}.zip verbose: true - task: PublishBuildArtifacts@1 inputs: pathToPublish: $(Build.ArtifactStagingDirectory) - artifactName: windows_release + artifactName: ${{ parameters.artifactName }} diff --git a/conanfile.py b/conanfile.py index 299e3159..dc5d1339 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,7 +35,11 @@ def set_version(self): requires = [ ("qt/5.15.2"), ("hobbits-cpython/3.9.7"), +<<<<<<< HEAD ("pffft/cci.20210511"), +======= + ("fftw/3.3.9"), +>>>>>>> 33613e926c8c452fb1d52cce22da97a06fb33d9b ("libusb/1.0.24") ] diff --git a/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py b/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py index f6b8a15d..c1b642aa 100644 --- a/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py +++ b/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py @@ -154,7 +154,7 @@ def parse_data(input_filename, output_filename, action_progress): module_file = os.path.basename(scripts[0]) sys.path.append(os.path.dirname(scripts[0])) package_name = os.path.splitext(module_file)[0] - class_name = package_name.capitalize() + class_name = "".join([s.capitalize() for s in package_name.split("_")]) try: del sys.modules[package_name] except KeyError: From b4ec06610ace66b9acb133b1dba84195f016d677 Mon Sep 17 00:00:00 2001 From: melissascode Date: Thu, 7 Oct 2021 11:43:46 -0400 Subject: [PATCH 23/26] Saved conanfile.py --- conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index dc5d1339..f86fc512 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,11 +35,7 @@ def set_version(self): requires = [ ("qt/5.15.2"), ("hobbits-cpython/3.9.7"), -<<<<<<< HEAD - ("pffft/cci.20210511"), -======= ("fftw/3.3.9"), ->>>>>>> 33613e926c8c452fb1d52cce22da97a06fb33d9b ("libusb/1.0.24") ] From bbc7f846b0f6726f6f2310d1660354ac524538c0 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 10 Oct 2021 19:14:04 -0400 Subject: [PATCH 24/26] Added pffft --- conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index f86fc512..c4c0ec6a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -36,7 +36,8 @@ def set_version(self): ("qt/5.15.2"), ("hobbits-cpython/3.9.7"), ("fftw/3.3.9"), - ("libusb/1.0.24") + ("libusb/1.0.24"), + ("pffft/cci.20210511") ] def requirements(self): From 8863da559ffaf4d6c82959e23dea788459515a71 Mon Sep 17 00:00:00 2001 From: melissascode Date: Sun, 10 Oct 2021 19:16:41 -0400 Subject: [PATCH 25/26] Added pffft to conanfile --- conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index c4c0ec6a..59b203c1 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,9 +35,9 @@ def set_version(self): requires = [ ("qt/5.15.2"), ("hobbits-cpython/3.9.7"), + ("pffft/cci.20210511"), ("fftw/3.3.9"), - ("libusb/1.0.24"), - ("pffft/cci.20210511") + ("libusb/1.0.24") ] def requirements(self): From 89ada5a68e362e6251f5906be124a8eb59efb633 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 4 Nov 2021 10:58:28 -0400 Subject: [PATCH 26/26] clean up some build/package loose ends --- CMakeLists.txt | 24 +- LICENSE.txt | 11 - cmake/FindFFTW.cmake | 419 ------------------ cmake/FindPFFFT.cmake | 40 ++ cmake/PackExternalDeps.cmake | 28 +- conanfile.py | 5 - src/hobbits-gui/CMakeLists.txt | 7 +- .../analyzers/WidthFramer/CMakeLists.txt | 6 +- .../displays/Spectrogram/CMakeLists.txt | 6 +- src/hobbits-runner/CMakeLists.txt | 7 +- 10 files changed, 60 insertions(+), 493 deletions(-) delete mode 100644 cmake/FindFFTW.cmake create mode 100644 cmake/FindPFFFT.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8680fd0f..1cc283d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,8 @@ if (BUILDING_WITH_CONAN) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CONAN_LIB_DIRS_QT}/cmake/Qt5Core") include(conan_qt_executables_variables) else() + find_package(PkgConfig) + # Qt find_package(Qt5Core CONFIG REQUIRED) find_package(Qt5Widgets CONFIG REQUIRED) @@ -98,15 +100,13 @@ else() find_package(PCAP REQUIRED) endif() - # FFTW - if (WIN32) - find_package(FFTW COMPONENTS DOUBLE_LIB REQUIRED) - else() - find_package(FFTW COMPONENTS DOUBLE_LIB DOUBLE_THREADS_LIB REQUIRED) + if(NOT WIN32) + # Libusb + find_package(libusb-1.0 REQUIRED) endif() - # Libusb - find_package(libusb-1.0 REQUIRED) + # PFFFT + find_package(PFFFT REQUIRED) endif() @@ -200,9 +200,9 @@ set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF) cpack_add_component("runtime") set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "hobbits") -set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libqt5core5a, libqt5widgets5, libqt5network5, libfftw3-3, libpcap0.8") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libqt5core5a, libqt5widgets5, libqt5network5, libpcap0.8") set(CPACK_RPM_RUNTIME_PACKAGE_NAME "hobbits") -set(CPACK_RPM_RUNTIME_PACKAGE_REQUIRES "qt5-qtbase, qt5-qtbase-gui, fftw, libpcap") +set(CPACK_RPM_RUNTIME_PACKAGE_REQUIRES "qt5-qtbase, qt5-qtbase-gui, libpcap") cpack_add_component("dev") set(CPACK_DEBIAN_DEV_PACKAGE_NAME "hobbits-dev") @@ -215,8 +215,8 @@ set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Hobbits Development Tools") set(CPACK_COMPONENTS_ALL runtime dev) -set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-qtbase-gui, fftw, libpcap") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt5-default, libfftw3-3, libpcap0.8") +set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-qtbase-gui, libpcap") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt5-default, libpcap0.8") set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) # @@ -234,7 +234,7 @@ if (NOT BUILDING_WITH_CONAN) if (SELF_CONTAINED_APP OR APPLE OR WIN32) pack_qt_libs() pack_python() - pack_fftw() + pack_pffft() pack_pcap() endif() include(CPack) diff --git a/LICENSE.txt b/LICENSE.txt index cc5c6c7e..56dc14ee 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,16 +1,5 @@ Copyright (c) 2020-2021 Mahlet, Inc. -IMPORTANT: While all the code in hobbits is released under the MIT License -(set out below), some capabilities require FFTW3. FFTW3 is available -under two licenses, the free GPL and a non-free license that allows it to be -used in proprietary programs. - -If you distribute FFTW3-enabled hobbits with the GPLed FFTW3 library, your code -must also be GPL licensed. If you do not wish to comply with the terms of the -GPL, you have to buy a FFTW3 license from the copyright holder, MIT. See -http://www.fftw.org/doc/License-and-Copyright.html for more information. - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake deleted file mode 100644 index ec1981eb..00000000 --- a/cmake/FindFFTW.cmake +++ /dev/null @@ -1,419 +0,0 @@ -# - Find the FFTW library -# -# Original version of this file: -# Copyright (c) 2015, Wenzel Jakob -# https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake, commit 4d58bfdc28891b4f9373dfe46239dda5a0b561c6 -# Modifications: -# Copyright (c) 2017, Patrick Bos -# -# Usage: -# find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] ) -# -# It sets the following variables: -# FFTW_FOUND ... true if fftw is found on the system -# FFTW_[component]_LIB_FOUND ... true if the component is found on the system (see components below) -# FFTW_LIBRARIES ... full paths to all found fftw libraries -# FFTW_[component]_LIB ... full path to one of the components (see below) -# FFTW_INCLUDE_DIRS ... fftw include directory paths -# -# The following variables will be checked by the function -# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found, otherwise both static and shared. -# FFTW_ROOT ... if set, the libraries are exclusively searched -# under this path -# -# This package supports the following components: -# FLOAT_LIB -# DOUBLE_LIB -# LONGDOUBLE_LIB -# FLOAT_THREADS_LIB -# DOUBLE_THREADS_LIB -# LONGDOUBLE_THREADS_LIB -# FLOAT_OPENMP_LIB -# DOUBLE_OPENMP_LIB -# LONGDOUBLE_OPENMP_LIB -# - -# TODO (maybe): extend with ExternalProject download + build option -# TODO: put on conda-forge - - -if( NOT FFTW_ROOT AND DEFINED ENV{FFTWDIR} ) - set( FFTW_ROOT $ENV{FFTWDIR} ) -endif() - -# Check if we can use PkgConfig -find_package(PkgConfig) - -#Determine from PKG -if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) - pkg_check_modules( PKG_FFTW QUIET "fftw3" ) -endif() - -#Check whether to search static or dynamic libs -set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} ) - -if( ${FFTW_USE_STATIC_LIBS} ) - set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ) -else() - set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) -endif() - -if( FFTW_ROOT ) - # find libs - - find_library( - FFTW_DOUBLE_LIB - NAMES "fftw3" libfftw3-3 - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_DOUBLE_THREADS_LIB - NAMES "fftw3_threads" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_DOUBLE_OPENMP_LIB - NAMES "fftw3_omp" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_DOUBLE_MPI_LIB - NAMES "fftw3_mpi" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_FLOAT_LIB - NAMES "fftw3f" libfftw3f-3 - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_FLOAT_THREADS_LIB - NAMES "fftw3f_threads" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_FLOAT_OPENMP_LIB - NAMES "fftw3f_omp" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_FLOAT_MPI_LIB - NAMES "fftw3f_mpi" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_LONGDOUBLE_LIB - NAMES "fftw3l" libfftw3l-3 - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_LONGDOUBLE_THREADS_LIB - NAMES "fftw3l_threads" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_LONGDOUBLE_OPENMP_LIB - NAMES "fftw3l_omp" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - find_library( - FFTW_LONGDOUBLE_MPI_LIB - NAMES "fftw3l_mpi" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "lib" "lib64" - NO_DEFAULT_PATH - ) - - #find includes - find_path(FFTW_INCLUDE_DIRS - NAMES "fftw3.h" - PATHS ${FFTW_ROOT} - PATH_SUFFIXES "include" - NO_DEFAULT_PATH - ) - -else() - - find_library( - FFTW_DOUBLE_LIB - NAMES "fftw3" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_DOUBLE_THREADS_LIB - NAMES "fftw3_threads" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_DOUBLE_OPENMP_LIB - NAMES "fftw3_omp" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_DOUBLE_MPI_LIB - NAMES "fftw3_mpi" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_FLOAT_LIB - NAMES "fftw3f" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_FLOAT_THREADS_LIB - NAMES "fftw3f_threads" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_FLOAT_OPENMP_LIB - NAMES "fftw3f_omp" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_FLOAT_MPI_LIB - NAMES "fftw3f_mpi" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_LONGDOUBLE_LIB - NAMES "fftw3l" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library( - FFTW_LONGDOUBLE_THREADS_LIB - NAMES "fftw3l_threads" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library(FFTW_LONGDOUBLE_OPENMP_LIB - NAMES "fftw3l_omp" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_library(FFTW_LONGDOUBLE_MPI_LIB - NAMES "fftw3l_mpi" - PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} - ) - - find_path(FFTW_INCLUDE_DIRS - NAMES "fftw3.h" - PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} - ) - -endif( FFTW_ROOT ) - -#--------------------------------------- components - -if (FFTW_DOUBLE_LIB) - set(FFTW_DOUBLE_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_LIB}) - add_library(FFTW::Double INTERFACE IMPORTED) - set_target_properties(FFTW::Double - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}" - ) -else() - set(FFTW_DOUBLE_LIB_FOUND FALSE) -endif() - -if (FFTW_FLOAT_LIB) - set(FFTW_FLOAT_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_LIB}) - add_library(FFTW::Float INTERFACE IMPORTED) - set_target_properties(FFTW::Float - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}" - ) -else() - set(FFTW_FLOAT_LIB_FOUND FALSE) -endif() - -if (FFTW_LONGDOUBLE_LIB) - set(FFTW_LONGDOUBLE_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_LIB}) - add_library(FFTW::LongDouble INTERFACE IMPORTED) - set_target_properties(FFTW::LongDouble - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}" - ) -else() - set(FFTW_LONGDOUBLE_LIB_FOUND FALSE) -endif() - -if (FFTW_DOUBLE_THREADS_LIB) - set(FFTW_DOUBLE_THREADS_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIB}) - add_library(FFTW::DoubleThreads INTERFACE IMPORTED) - set_target_properties(FFTW::DoubleThreads - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_THREADS_LIB}" - ) -else() - set(FFTW_DOUBLE_THREADS_LIB_FOUND FALSE) -endif() - -if (FFTW_FLOAT_THREADS_LIB) - set(FFTW_FLOAT_THREADS_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_THREADS_LIB}) - add_library(FFTW::FloatThreads INTERFACE IMPORTED) - set_target_properties(FFTW::FloatThreads - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}" - ) -else() - set(FFTW_FLOAT_THREADS_LIB_FOUND FALSE) -endif() - -if (FFTW_LONGDOUBLE_THREADS_LIB) - set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_THREADS_LIB}) - add_library(FFTW::LongDoubleThreads INTERFACE IMPORTED) - set_target_properties(FFTW::LongDoubleThreads - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}" - ) -else() - set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND FALSE) -endif() - -if (FFTW_DOUBLE_OPENMP_LIB) - set(FFTW_DOUBLE_OPENMP_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_OPENMP_LIB}) - add_library(FFTW::DoubleOpenMP INTERFACE IMPORTED) - set_target_properties(FFTW::DoubleOpenMP - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}" - ) -else() - set(FFTW_DOUBLE_OPENMP_LIB_FOUND FALSE) -endif() - -if (FFTW_FLOAT_OPENMP_LIB) - set(FFTW_FLOAT_OPENMP_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_OPENMP_LIB}) - add_library(FFTW::FloatOpenMP INTERFACE IMPORTED) - set_target_properties(FFTW::FloatOpenMP - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}" - ) -else() - set(FFTW_FLOAT_OPENMP_LIB_FOUND FALSE) -endif() - -if (FFTW_LONGDOUBLE_OPENMP_LIB) - set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_OPENMP_LIB}) - add_library(FFTW::LongDoubleOpenMP INTERFACE IMPORTED) - set_target_properties(FFTW::LongDoubleOpenMP - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}" - ) -else() - set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND FALSE) -endif() - -if (FFTW_DOUBLE_MPI_LIB) - set(FFTW_DOUBLE_MPI_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_MPI_LIB}) - add_library(FFTW::DoubleMPI INTERFACE IMPORTED) - set_target_properties(FFTW::DoubleMPI - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_MPI_LIB}" - ) -else() - set(FFTW_DOUBLE_MPI_LIB_FOUND FALSE) -endif() - -if (FFTW_FLOAT_MPI_LIB) - set(FFTW_FLOAT_MPI_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_MPI_LIB}) - add_library(FFTW::FloatMPI INTERFACE IMPORTED) - set_target_properties(FFTW::FloatMPI - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_MPI_LIB}" - ) -else() - set(FFTW_FLOAT_MPI_LIB_FOUND FALSE) -endif() - -if (FFTW_LONGDOUBLE_MPI_LIB) - set(FFTW_LONGDOUBLE_MPI_LIB_FOUND TRUE) - set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_MPI_LIB}) - add_library(FFTW::LongDoubleMPI INTERFACE IMPORTED) - set_target_properties(FFTW::LongDoubleMPI - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_MPI_LIB}" - ) -else() - set(FFTW_LONGDOUBLE_MPI_LIB_FOUND FALSE) -endif() - -#--------------------------------------- end components - -set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(FFTW - REQUIRED_VARS FFTW_INCLUDE_DIRS - HANDLE_COMPONENTS - ) - -mark_as_advanced( - FFTW_INCLUDE_DIRS - FFTW_LIBRARIES - FFTW_FLOAT_LIB - FFTW_DOUBLE_LIB - FFTW_LONGDOUBLE_LIB - FFTW_FLOAT_THREADS_LIB - FFTW_DOUBLE_THREADS_LIB - FFTW_LONGDOUBLE_THREADS_LIB - FFTW_FLOAT_OPENMP_LIB - FFTW_DOUBLE_OPENMP_LIB - FFTW_LONGDOUBLE_OPENMP_LIB - FFTW_FLOAT_MPI_LIB - FFTW_DOUBLE_MPI_LIB - FFTW_LONGDOUBLE_MPI_LIB - ) diff --git a/cmake/FindPFFFT.cmake b/cmake/FindPFFFT.cmake new file mode 100644 index 00000000..9a95ded3 --- /dev/null +++ b/cmake/FindPFFFT.cmake @@ -0,0 +1,40 @@ +find_path( + PFFFT_INCLUDE_DIRS pffft.h + PATHS + ENV PFFFT_ROOT + ENV PFFFT_INCLUDE_DIR + ${PFFFT_ROOT} + /usr + /usr/local + PATH_SUFFIXES + ${CMAKE_INSTALL_INCLUDEDIR} +) +find_library( + PFFFT_LIBRARIES NAMES pffft + PATHS + ENV PFFFT_ROOT + ENV PFFFT_LIB_DIR + ${PFFFT_ROOT} + /usr + /usr/local + PATH_SUFFIXES + ${CMAKE_INSTALL_LIBDIR} +) + +include( FindPackageHandleStandardArgs ) +find_package_handle_standard_args( + PFFFT + DEFAULT_MSG + PFFFT_INCLUDE_DIRS + PFFFT_LIBRARIES +) + +if( PFFFT_FOUND AND NOT TARGET PFFFT::PFFFT ) + add_library( PFFFT::PFFFT UNKNOWN IMPORTED ) + set_target_properties( + PFFFT::PFFFT PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${PFFFT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${PFFFT_INCLUDE_DIRS}" + ) +endif() diff --git a/cmake/PackExternalDeps.cmake b/cmake/PackExternalDeps.cmake index 6d70b1e6..4be07c75 100644 --- a/cmake/PackExternalDeps.cmake +++ b/cmake/PackExternalDeps.cmake @@ -142,30 +142,10 @@ function(pack_python) endif() endfunction(pack_python) -function(pack_fftw) - if (LINUX) - get_target_property(FFTWLIB FFTW::Double INTERFACE_LINK_LIBRARIES) - string(REGEX REPLACE \.so\..*$ ".so" BASELIB ${FFTWLIB}) - file(GLOB FFTWLIBS "${BASELIB}*") - install(FILES ${FFTWLIBS} - DESTINATION "${CMAKE_INSTALL_LIBDIR}") - get_target_property(FFTWLIB_T FFTW::DoubleThreads INTERFACE_LINK_LIBRARIES) - string(REGEX REPLACE \.so\..*$ ".so" BASELIB_T ${FFTWLIB_T}) - file(GLOB FFTW_T_LIBS "${BASELIB_T}*") - install(FILES ${FFTW_T_LIBS} - DESTINATION "${CMAKE_INSTALL_LIBDIR}") - elseif(APPLE) - file(GLOB FFTWLIBS "/usr/local/opt/fftw/lib/fftw3.*dylib") - install(FILES ${FFTWLIBS} - DESTINATION "hobbits.app/Contents/Frameworks") - file(GLOB FFTW_T_LIBS "/usr/local/opt/fftw/lib/fftw3_threads.*dylib") - install(FILES ${FFTW_T_LIBS} - DESTINATION "hobbits.app/Contents/Frameworks") - elseif(WIN32) - install(FILES "${CMAKE_SOURCE_DIR}/windows/libfftw3-3.dll" - DESTINATION ".") - endif() -endfunction(pack_fftw) +function(pack_pffft) + install(FILES ${PFFFT_LIBRARIES} + DESTINATION "${CMAKE_INSTALL_LIBDIR}") +endfunction(pack_pcap) function(pack_pcap) if (LINUX) diff --git a/conanfile.py b/conanfile.py index 59b203c1..21ffdd9c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,10 +23,7 @@ def set_version(self): "shared": True, "fPIC": True, "qt:shared": True, - "fftw:shared": True, "libpcap:shared": True, - "fftw:threads": True, - "fftw:combinedthreads": True, "icu:shared":False } generators = "cmake" @@ -36,7 +33,6 @@ def set_version(self): ("qt/5.15.2"), ("hobbits-cpython/3.9.7"), ("pffft/cci.20210511"), - ("fftw/3.3.9"), ("libusb/1.0.24") ] @@ -49,7 +45,6 @@ def config_options(self): del self.options.fPIC elif self.settings.os == "Macos": self.options['libpcap'].shared = False - self.options['fftw'].shared = False def _configure_cmake(self): cmake = CMake(self) diff --git a/src/hobbits-gui/CMakeLists.txt b/src/hobbits-gui/CMakeLists.txt index 66e4859e..42357701 100644 --- a/src/hobbits-gui/CMakeLists.txt +++ b/src/hobbits-gui/CMakeLists.txt @@ -17,14 +17,9 @@ file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DI if (BUILDING_WITH_CONAN) - set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::pffft) + set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt) else() set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets) - if(WIN32) - list(APPEND ALL_LINK_LIBS FFTW::Double) - else() - list(APPEND ALL_LINK_LIBS FFTW::Double FFTW::DoubleThreads) - endif() endif() add_executable(hobbits MACOSX_BUNDLE "${SRCFILES}" "${HDRFILES}" "${RCFILES}") diff --git a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt index 3063d4df..e9c92818 100644 --- a/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt +++ b/src/hobbits-plugins/analyzers/WidthFramer/CMakeLists.txt @@ -4,11 +4,7 @@ pluginInDir("${pluginType}" "WidthFramer" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE CONAN_PKG::pffft) else() - if(WIN32) - target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE FFTW::Double) - else() - target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE FFTW::Double FFTW::DoubleThreads) - endif() + target_link_libraries("hobbits-plugin-analyzers-WidthFramer" PRIVATE PFFFT::PFFFT) endif() diff --git a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt index e381b304..79d3802f 100644 --- a/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt +++ b/src/hobbits-plugins/displays/Spectrogram/CMakeLists.txt @@ -5,9 +5,5 @@ pluginInDir("${pluginType}" "Spectrogram" "${CMAKE_CURRENT_SOURCE_DIR}") if (BUILDING_WITH_CONAN) target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE CONAN_PKG::pffft) else() - if(WIN32) - target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE FFTW::Double) - else() - target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE FFTW::Double FFTW::DoubleThreads) - endif() + target_link_libraries("hobbits-plugin-displays-Spectrogram" PRIVATE PFFFT::PFFFT) endif() diff --git a/src/hobbits-runner/CMakeLists.txt b/src/hobbits-runner/CMakeLists.txt index a0c1b0c8..d42fe82a 100644 --- a/src/hobbits-runner/CMakeLists.txt +++ b/src/hobbits-runner/CMakeLists.txt @@ -17,14 +17,9 @@ file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DI add_executable("hobbits-runner" "${SRCFILES}" "${HDRFILES}" "${RCFILES}") if (BUILDING_WITH_CONAN) - set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt CONAN_PKG::pffft) + set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core CONAN_PKG::qt) else() set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets) - if(WIN32) - list(APPEND ALL_LINK_LIBS FFTW::Double) - else() - list(APPEND ALL_LINK_LIBS FFTW::Double FFTW::DoubleThreads) - endif() endif() target_link_libraries("hobbits-runner" ${ALL_LINK_LIBS})