mirror of https://github.com/EspoTek/Labrador.git
fix : correct mapping for frequencies
Signed-off-by: Vincenzo Petrolo <vincenzo@kernel-space.org>
This commit is contained in:
parent
d08a1775c7
commit
bdf01b5ffb
|
@ -1,6 +1,7 @@
|
|||
#include "asyncdft.h"
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include "isobuffer.h"
|
||||
#define DBG 0
|
||||
|
||||
|
||||
|
@ -15,7 +16,7 @@ AsyncDFT::AsyncDFT()
|
|||
/*Initializing time domain window to 0s*/
|
||||
/*FFTW3 inits*/
|
||||
fftw_init_threads();
|
||||
fftw_plan_with_nthreads(omp_get_max_threads());
|
||||
fftw_plan_with_nthreads(omp_get_max_threads() * 2);
|
||||
#if DBG
|
||||
std::cout << "Starting with " << omp_get_max_threads() << "threads" << std::endl;
|
||||
#endif
|
||||
|
@ -114,14 +115,12 @@ QVector<double> AsyncDFT::getPowerSpectrum(QVector<double> input)
|
|||
return amplitude;
|
||||
}
|
||||
|
||||
QVector<double> AsyncDFT::getFrequenciyWindow()
|
||||
QVector<double> AsyncDFT::getFrequenciyWindow(int samplesPerSeconds)
|
||||
{
|
||||
int max_freq = 62500;
|
||||
double delta_freq = ((double) 350000)/ ((double) n_samples);
|
||||
int tot = max_freq/delta_freq + 1;
|
||||
QVector<double> f(tot);
|
||||
double delta_freq = ((double) samplesPerSeconds)/ ((double) n_samples);
|
||||
QVector<double> f(n_samples/2 + 1);
|
||||
|
||||
for (int i = 0; i < tot; i++) {
|
||||
for (int i = 0; i < n_samples/2 + 1; i++) {
|
||||
f[i] = i*delta_freq;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@ class AsyncDFT
|
|||
public:
|
||||
AsyncDFT();
|
||||
~AsyncDFT();
|
||||
static const int n_samples = 350000;
|
||||
static const int n_samples = 1<<17;
|
||||
|
||||
/* Raise exception if not ready yet*/
|
||||
QVector<double> getPowerSpectrum(QVector<double> input);
|
||||
QVector<double> getFrequenciyWindow();
|
||||
QVector<double> getFrequenciyWindow(int samplesPerSeconds);
|
||||
|
||||
/*Add a sample to the time domain samples*/
|
||||
void addSample(short sample);
|
||||
|
|
|
@ -740,7 +740,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode)
|
|||
if (spectrum) { /*If frequency spectrum mode*/
|
||||
try {
|
||||
QVector<double> amplitude = internalBuffer375_CH1->async_dft.getPowerSpectrum(converted_dt_samples);
|
||||
QVector<double> f = internalBuffer375_CH1->async_dft.getFrequenciyWindow();
|
||||
QVector<double> f = internalBuffer375_CH1->async_dft.getFrequenciyWindow(internalBuffer375_CH1->m_samplesPerSecond);
|
||||
double maximum = internalBuffer375_CH1->async_dft.maximum;
|
||||
axes->graph(0)->setData(f,amplitude);
|
||||
#if 0
|
||||
|
@ -749,7 +749,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode)
|
|||
axes->graph(1)->setData(f,amplitude);
|
||||
}
|
||||
#endif
|
||||
axes->xAxis->setRange(f.length(), 0);
|
||||
axes->xAxis->setRange(f.last(), f.front());
|
||||
axes->yAxis->setRange(maximum,0);
|
||||
} catch (std::exception) {
|
||||
std::cout << "Cannot yet get correct value for DFT" << std::endl;
|
||||
|
|
Loading…
Reference in New Issue