mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-10 09:54:48 -04:00
Clean up redundant internal FFTW3 support; liquid-dsp will use FFTW3 if compiled in.
This commit is contained in:
@@ -9,42 +9,19 @@ ScopeVisualProcessor::ScopeVisualProcessor(): outputBuffers("ScopeVisualProcesso
|
||||
fft_ceil_ma = fft_ceil_maa = 0;
|
||||
fft_floor_ma = fft_floor_maa = 0;
|
||||
maxScopeSamples = 1024;
|
||||
#if USE_FFTW3
|
||||
fftw_plan = nullptr;
|
||||
#else
|
||||
fftPlan = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
ScopeVisualProcessor::~ScopeVisualProcessor() {
|
||||
#if USE_FFTW3
|
||||
if (fftw_plan) {
|
||||
fftwf_destroy_plan(fftw_plan);
|
||||
}
|
||||
|
||||
#else
|
||||
if (fftPlan) {
|
||||
fft_destroy_plan(fftPlan);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ScopeVisualProcessor::setup(int fftSize_in) {
|
||||
fftSize = fftSize_in;
|
||||
desiredInputSize = fftSize;
|
||||
|
||||
#if USE_FFTW3
|
||||
|
||||
fftInData.resize(fftSize);
|
||||
fftwOutput.resize(fftSize);
|
||||
|
||||
if (fftw_plan) {
|
||||
fftwf_destroy_plan(fftw_plan);
|
||||
}
|
||||
fftw_plan = fftwf_plan_dft_r2c_1d(fftSize, fftInData.data(), fftwOutput.data(), FFTW_ESTIMATE);
|
||||
#else
|
||||
|
||||
fftInData.resize(fftSize);
|
||||
fftOutput.resize(fftSize);
|
||||
@@ -53,7 +30,6 @@ void ScopeVisualProcessor::setup(int fftSize_in) {
|
||||
fft_destroy_plan(fftPlan);
|
||||
}
|
||||
fftPlan = fft_create_plan(fftSize, fftInData.data(), fftOutput.data(), LIQUID_FFT_FORWARD, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScopeVisualProcessor::setScopeEnabled(bool scopeEnable) {
|
||||
@@ -142,26 +118,6 @@ void ScopeVisualProcessor::process() {
|
||||
if (spectrumEnabled) {
|
||||
iMax = audioInputData->data.size();
|
||||
|
||||
#if USE_FFTW3
|
||||
if (audioInputData->channels==1) {
|
||||
for (i = 0; i < fftSize; i++) {
|
||||
if (i < iMax) {
|
||||
fftInData[i] = audioInputData->data[i];
|
||||
} else {
|
||||
fftInData[i] = 0;
|
||||
}
|
||||
}
|
||||
} else if (audioInputData->channels==2) {
|
||||
iMax = iMax/2;
|
||||
for (i = 0; i < fftSize; i++) {
|
||||
if (i < iMax) {
|
||||
fftInData[i] = audioInputData->data[i] + audioInputData->data[iMax+i];
|
||||
} else {
|
||||
fftInData[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (audioInputData->channels==1) {
|
||||
for (i = 0; i < fftSize; i++) {
|
||||
if (i < iMax) {
|
||||
@@ -184,7 +140,6 @@ void ScopeVisualProcessor::process() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
renderData = outputBuffers.getBuffer();
|
||||
|
||||
@@ -202,19 +157,6 @@ void ScopeVisualProcessor::process() {
|
||||
fft_result_maa.resize((fftSize/2));
|
||||
}
|
||||
|
||||
#if USE_FFTW3
|
||||
fftwf_execute(fftw_plan);
|
||||
|
||||
for (i = 0; i < (fftSize/2); i++) {
|
||||
//cast result to double to prevent overflows / excessive precision losses in the following computations...
|
||||
double a = (double) fftwOutput[i][0];
|
||||
double b = (double) fftwOutput[i][1];
|
||||
|
||||
//computes norm = sqrt(a**2 + b**2)
|
||||
//being actually floats cast into doubles, we are indeed overflow-free here.
|
||||
fft_result[i] = sqrt(a*a + b*b);
|
||||
}
|
||||
#else
|
||||
fft_execute(fftPlan);
|
||||
for (i = 0; i < (fftSize/2); i++) {
|
||||
|
||||
@@ -226,7 +168,6 @@ void ScopeVisualProcessor::process() {
|
||||
//being actually floats cast into doubles, we are indeed overflow-free here.
|
||||
fft_result[i] = sqrt(a*a + b*b);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < (fftSize/2); i++) {
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
|
||||
Reference in New Issue
Block a user