CubicSDR/src/process/ScopeVisualProcessor.h
vsonnier c64baab99d Threads vs. Queues lifetimes, cleanups.
- Ideally Queues must outlive the threads using them, but wasn't done so. Yes, std::shared_ptr them!
- Now queues are always valid in the context of the threads using them.
- No longer need tedious queues deallocation by the original owner.
- Misc cleanups.
2017-08-13 19:19:25 +02:00

63 lines
1.5 KiB
C++

// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
#pragma once
#include "VisualProcessor.h"
#include "AudioThread.h"
#include "ScopePanel.h"
#include <memory>
class ScopeRenderData {
public:
std::vector<float> waveform_points;
ScopePanel::ScopeMode mode = ScopePanel::SCOPE_MODE_Y;
int inputRate;
int sampleRate;
int channels;
bool spectrum;
int fft_size;
double fft_floor, fft_ceil;
virtual ~ScopeRenderData() {
}
};
typedef std::shared_ptr<ScopeRenderData> ScopeRenderDataPtr;
typedef ThreadBlockingQueue<ScopeRenderDataPtr> ScopeRenderDataQueue;
typedef std::shared_ptr<ScopeRenderDataQueue> ScopeRenderDataQueuePtr;
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInput, ScopeRenderData> {
public:
ScopeVisualProcessor();
~ScopeVisualProcessor();
void setup(int fftSize_in);
void setScopeEnabled(bool scopeEnable);
void setSpectrumEnabled(bool spectrumEnable);
protected:
virtual void process();
ReBuffer<ScopeRenderData> outputBuffers;
std::atomic_bool scopeEnabled;
std::atomic_bool spectrumEnabled;
std::vector<liquid_float_complex> fftInData;
std::vector<liquid_float_complex> fftOutput;
fftplan fftPlan;
unsigned int fftSize = 0;
int desiredInputSize;
unsigned int maxScopeSamples;
double fft_ceil_ma, fft_ceil_maa;
double fft_floor_ma, fft_floor_maa;
double fft_average_rate;
std::vector<double> fft_result;
std::vector<double> fft_result_ma;
std::vector<double> fft_result_maa;
};