Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Hoernchen | 834b192eb4 | |
Hoernchen | e30c4191d1 |
|
@ -84,7 +84,7 @@ private:
|
||||||
typedef std::list<SampleSink*> SampleSinks;
|
typedef std::list<SampleSink*> SampleSinks;
|
||||||
SampleSinks m_sampleSinks;
|
SampleSinks m_sampleSinks;
|
||||||
|
|
||||||
AudioOutput m_audioOutput;
|
//AudioOutput m_audioOutput;
|
||||||
|
|
||||||
uint m_sampleRate;
|
uint m_sampleRate;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef INCLUDE_FFTSEngine_H
|
||||||
|
#define INCLUDE_FFTSEngine_H
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
#include <ffts/ffts.h>
|
||||||
|
#include <list>
|
||||||
|
#include "dsp/fftengine.h"
|
||||||
|
|
||||||
|
class FFTSEngine : public FFTEngine {
|
||||||
|
public:
|
||||||
|
FFTSEngine();
|
||||||
|
~FFTSEngine();
|
||||||
|
|
||||||
|
void configure(int n, bool inverse);
|
||||||
|
void transform();
|
||||||
|
|
||||||
|
Complex* in();
|
||||||
|
Complex* out();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void allocate(int n);
|
||||||
|
ffts_plan_t* m_currentplan;
|
||||||
|
void *imem;
|
||||||
|
void *iptr;
|
||||||
|
void *omem;
|
||||||
|
void *optr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INCLUDE_FFTSEngine_H
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef INCLUDE_INTERPOLATOR_H
|
#ifndef INCLUDE_INTERPOLATOR_H
|
||||||
#define INCLUDE_INTERPOLATOR_H
|
#define INCLUDE_INTERPOLATOR_H
|
||||||
|
|
||||||
|
#if 0
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
#endif
|
||||||
#include "dsp/dsptypes.h"
|
#include "dsp/dsptypes.h"
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -55,7 +57,7 @@ private:
|
||||||
|
|
||||||
void doInterpolate(int phase, Complex* result)
|
void doInterpolate(int phase, Complex* result)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
// beware of the ringbuffer
|
// beware of the ringbuffer
|
||||||
if(m_ptr == 0) {
|
if(m_ptr == 0) {
|
||||||
// only one straight block
|
// only one straight block
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QtOpenGL/qglshaderprogram.h>
|
||||||
#include "dsp/dsptypes.h"
|
#include "dsp/dsptypes.h"
|
||||||
#include "gui/scaleengine.h"
|
#include "gui/scaleengine.h"
|
||||||
#include "dsp/channelmarker.h"
|
#include "dsp/channelmarker.h"
|
||||||
|
@ -131,12 +132,19 @@ private:
|
||||||
|
|
||||||
bool m_displayChanged;
|
bool m_displayChanged;
|
||||||
|
|
||||||
|
QGLShaderProgram shaderprog;
|
||||||
|
int vertexAtt;
|
||||||
|
int texcoordAtt;
|
||||||
|
int matrixUni;
|
||||||
|
int texUni;
|
||||||
|
|
||||||
void updateWaterfall(const std::vector<Real>& spectrum);
|
void updateWaterfall(const std::vector<Real>& spectrum);
|
||||||
void updateHistogram(const std::vector<Real>& spectrum);
|
void updateHistogram(const std::vector<Real>& spectrum);
|
||||||
|
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void resizeGL(int width, int height);
|
void resizeGL(int width, int height);
|
||||||
void paintGL();
|
void paintGL();
|
||||||
|
void GLtexBox();
|
||||||
|
|
||||||
void stopDrag();
|
void stopDrag();
|
||||||
void applyChanges();
|
void applyChanges();
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
void initeglcompat();
|
||||||
|
void glPushMatrix();
|
||||||
|
void glPopMatrix();
|
||||||
|
void glScalef(float x, float y, float z);
|
||||||
|
void glTranslatef(float x, float y, float z);
|
||||||
|
|
||||||
|
QMatrix4x4 getMV();
|
|
@ -1,6 +1,6 @@
|
||||||
#include "rtlsdrgui.h"
|
#include "rtlsdrgui.h"
|
||||||
#include "ui_rtlsdrgui.h"
|
#include "ui_rtlsdrgui.h"
|
||||||
#include "plugin/pluginapi.h"
|
#include <plugin/pluginapi.h>
|
||||||
|
|
||||||
RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
|
RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
|
|
@ -34,7 +34,7 @@ RTLSDRInput::Settings::Settings() :
|
||||||
void RTLSDRInput::Settings::resetToDefaults()
|
void RTLSDRInput::Settings::resetToDefaults()
|
||||||
{
|
{
|
||||||
m_gain = 0;
|
m_gain = 0;
|
||||||
m_decimation = 0;
|
m_decimation = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RTLSDRInput::Settings::serialize() const
|
QByteArray RTLSDRInput::Settings::serialize() const
|
||||||
|
@ -111,7 +111,7 @@ bool RTLSDRInput::startInput(int device)
|
||||||
qDebug("RTLSDRInput open: %s %s, SN: %s", vendor, product, serial);
|
qDebug("RTLSDRInput open: %s %s, SN: %s", vendor, product, serial);
|
||||||
m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial);
|
m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial);
|
||||||
|
|
||||||
if((res = rtlsdr_set_sample_rate(m_dev, 2000000)) < 0) {
|
if((res = rtlsdr_set_sample_rate(m_dev, 1000000)) < 0) {
|
||||||
qCritical("could not set sample rate: %s", strerror(errno));
|
qCritical("could not set sample rate: %s", strerror(errno));
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ const QString& RTLSDRInput::getDeviceDescription() const
|
||||||
|
|
||||||
int RTLSDRInput::getSampleRate() const
|
int RTLSDRInput::getSampleRate() const
|
||||||
{
|
{
|
||||||
return 2000000 / (1 << m_settings.m_decimation);
|
return 1000000 / (1 << m_settings.m_decimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 RTLSDRInput::getCenterFrequency() const
|
quint64 RTLSDRInput::getCenterFrequency() const
|
||||||
|
|
|
@ -325,7 +325,7 @@ DSPEngine::State DSPEngine::gotoIdle()
|
||||||
(*it)->stop();
|
(*it)->stop();
|
||||||
m_sampleSource->stopInput();
|
m_sampleSource->stopInput();
|
||||||
m_deviceDescription.clear();
|
m_deviceDescription.clear();
|
||||||
m_audioOutput.stop();
|
//m_audioOutput.stop();
|
||||||
m_sampleRate = 0;
|
m_sampleRate = 0;
|
||||||
|
|
||||||
return StIdle;
|
return StIdle;
|
||||||
|
@ -357,7 +357,7 @@ DSPEngine::State DSPEngine::gotoRunning()
|
||||||
return gotoError("Could not start sample source");
|
return gotoError("Could not start sample source");
|
||||||
m_deviceDescription = m_sampleSource->getDeviceDescription();
|
m_deviceDescription = m_sampleSource->getDeviceDescription();
|
||||||
|
|
||||||
m_audioOutput.start(0, 44100);
|
//m_audioOutput.start(0, 44100);
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
(*it)->start();
|
(*it)->start();
|
||||||
m_sampleRate = 0; // make sure, report is sent
|
m_sampleRate = 0; // make sure, report is sent
|
||||||
|
@ -489,10 +489,10 @@ void DSPEngine::handleMessages()
|
||||||
m_sampleSinks.remove(sink);
|
m_sampleSinks.remove(sink);
|
||||||
message->completed();
|
message->completed();
|
||||||
} else if(DSPAddAudioSource::match(message)) {
|
} else if(DSPAddAudioSource::match(message)) {
|
||||||
m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
//m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
||||||
message->completed();
|
message->completed();
|
||||||
} else if(DSPRemoveAudioSource::match(message)) {
|
} else if(DSPRemoveAudioSource::match(message)) {
|
||||||
m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
//m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
||||||
message->completed();
|
message->completed();
|
||||||
} else if(DSPConfigureCorrection::match(message)) {
|
} else if(DSPConfigureCorrection::match(message)) {
|
||||||
DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message;
|
DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#ifdef USE_FFTW
|
#ifdef USE_FFTW
|
||||||
#include "dsp/fftwengine.h"
|
#include "dsp/fftwengine.h"
|
||||||
#endif // USE_FFTW
|
#endif // USE_FFTW
|
||||||
|
#ifdef USE_FFTS
|
||||||
|
#include "dsp/fftsengine.h"
|
||||||
|
#endif // USE_FFTS
|
||||||
|
|
||||||
FFTEngine::~FFTEngine()
|
FFTEngine::~FFTEngine()
|
||||||
{
|
{
|
||||||
|
@ -20,7 +23,10 @@ FFTEngine* FFTEngine::create()
|
||||||
qDebug("FFT: using KissFFT engine");
|
qDebug("FFT: using KissFFT engine");
|
||||||
return new KissEngine;
|
return new KissEngine;
|
||||||
#endif // USE_KISSFFT
|
#endif // USE_KISSFFT
|
||||||
|
#ifdef USE_FFTS
|
||||||
|
qDebug("FFT: using FFTS engine");
|
||||||
|
return new FFTSEngine;
|
||||||
|
#endif // USE_FFTS
|
||||||
qCritical("FFT: no engine built");
|
qCritical("FFT: no engine built");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include <QTime>
|
||||||
|
#include "dsp/fftsengine.h"
|
||||||
|
|
||||||
|
FFTSEngine::FFTSEngine() :
|
||||||
|
m_currentplan(ffts_init_1d(1024, 1))
|
||||||
|
{
|
||||||
|
allocate(4096);
|
||||||
|
}
|
||||||
|
|
||||||
|
FFTSEngine::~FFTSEngine()
|
||||||
|
{
|
||||||
|
ffts_free(m_currentplan);
|
||||||
|
free(imem);
|
||||||
|
free(omem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFTSEngine::allocate(int n)
|
||||||
|
{
|
||||||
|
imem = malloc(n*4*2+15);
|
||||||
|
iptr = (void*)(((unsigned long)imem+15) & (unsigned long)(~ 0x0F));
|
||||||
|
omem = malloc(n*4*2+15);
|
||||||
|
optr = (void*)(((unsigned long)omem+15) & (unsigned long)(~ 0x0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFTSEngine::configure(int n, bool inverse)
|
||||||
|
{
|
||||||
|
ffts_free(m_currentplan);
|
||||||
|
m_currentplan = ffts_init_1d(n, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFTSEngine::transform()
|
||||||
|
{
|
||||||
|
ffts_execute(m_currentplan, iptr, optr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Complex* FFTSEngine::in()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<Complex*>(iptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Complex* FFTSEngine::out()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<Complex*>(optr);
|
||||||
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@
|
||||||
|
|
||||||
#define MAX_FFT_SIZE 4096
|
#define MAX_FFT_SIZE 4096
|
||||||
|
|
||||||
#ifdef _WIN32
|
inline float log2f(float f)
|
||||||
double log2f(double n)
|
|
||||||
{
|
{
|
||||||
return log(n) / log(2.0);
|
return logf(f) * (float) (1.0 / M_LN2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
|
SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
|
||||||
SampleSink(),
|
SampleSink(),
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
#include "gui/glscope.h"
|
#include "gui/glscope.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
static double log2f(double n)
|
|
||||||
|
inline float log2f(float f)
|
||||||
{
|
{
|
||||||
return log(n) / log(2.0);
|
return logf(f) * (float) (1.0 / M_LN2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
GLScope::GLScope(QWidget* parent) :
|
GLScope::GLScope(QWidget* parent) :
|
||||||
QGLWidget(parent),
|
QGLWidget(parent),
|
||||||
|
@ -110,6 +111,7 @@ void GLScope::resizeGL(int width, int height)
|
||||||
|
|
||||||
void GLScope::paintGL()
|
void GLScope::paintGL()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(!m_mutex.tryLock(2))
|
if(!m_mutex.tryLock(2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -172,7 +174,7 @@ void GLScope::paintGL()
|
||||||
glScalef(m_glScopeRect1.width(), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
|
glScalef(m_glScopeRect1.width(), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
//glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glColor4f(0, 1, 0, 0.3f);
|
glColor4f(0, 1, 0, 0.3f);
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
|
@ -184,7 +186,7 @@ void GLScope::paintGL()
|
||||||
glVertex2f(0, m_triggerLevelLow);
|
glVertex2f(0, m_triggerLevelLow);
|
||||||
glVertex2f(1, m_triggerLevelLow);
|
glVertex2f(1, m_triggerLevelLow);
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LINE_SMOOTH);
|
//glDisable(GL_LINE_SMOOTH);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +196,7 @@ void GLScope::paintGL()
|
||||||
glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
|
glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
//glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glColor4f(1, 1, 0, 0.4f);
|
glColor4f(1, 1, 0, 0.4f);
|
||||||
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
|
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
|
||||||
|
@ -213,7 +215,7 @@ void GLScope::paintGL()
|
||||||
glVertex2f(i - start, v);
|
glVertex2f(i - start, v);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LINE_SMOOTH);
|
//glDisable(GL_LINE_SMOOTH);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +261,7 @@ void GLScope::paintGL()
|
||||||
glScalef(m_glScopeRect2.width(), -(m_glScopeRect2.height() / 2) * m_amp2, 1);
|
glScalef(m_glScopeRect2.width(), -(m_glScopeRect2.height() / 2) * m_amp2, 1);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
//glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glColor4f(0, 1, 0, 0.3f);
|
glColor4f(0, 1, 0, 0.3f);
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
|
@ -271,7 +273,7 @@ void GLScope::paintGL()
|
||||||
glVertex2f(0, m_triggerLevelLow);
|
glVertex2f(0, m_triggerLevelLow);
|
||||||
glVertex2f(1, m_triggerLevelLow);
|
glVertex2f(1, m_triggerLevelLow);
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LINE_SMOOTH);
|
//glDisable(GL_LINE_SMOOTH);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +283,7 @@ void GLScope::paintGL()
|
||||||
glScalef(m_glScopeRect2.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect2.height() / 2) * m_amp2, 1);
|
glScalef(m_glScopeRect2.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect2.height() / 2) * m_amp2, 1);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
//glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glColor4f(1, 1, 0, 0.4f);
|
glColor4f(1, 1, 0, 0.4f);
|
||||||
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
|
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
|
||||||
|
@ -300,13 +302,14 @@ void GLScope::paintGL()
|
||||||
glVertex2f(i - start, v);
|
glVertex2f(i - start, v);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LINE_SMOOTH);
|
//glDisable(GL_LINE_SMOOTH);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
m_dataChanged = false;
|
m_dataChanged = false;
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLScope::mousePressEvent(QMouseEvent* event)
|
void GLScope::mousePressEvent(QMouseEvent* event)
|
||||||
|
|
|
@ -15,9 +15,12 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if 0
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
#endif
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include "gui/glspectrum.h"
|
#include "gui/glspectrum.h"
|
||||||
|
#include "util/glmath.h"
|
||||||
|
|
||||||
GLSpectrum::GLSpectrum(QWidget* parent) :
|
GLSpectrum::GLSpectrum(QWidget* parent) :
|
||||||
QGLWidget(parent),
|
QGLWidget(parent),
|
||||||
|
@ -315,7 +318,7 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
|
||||||
m_histogramHoldoffCount = m_histogramHoldoffBase;
|
m_histogramHoldoffCount = m_histogramHoldoffBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define NO_AVX
|
#define NO_AVX
|
||||||
#ifdef NO_AVX
|
#ifdef NO_AVX
|
||||||
for(int i = 0; i < m_fftSize; i++) {
|
for(int i = 0; i < m_fftSize; i++) {
|
||||||
int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
|
int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
|
||||||
|
@ -398,7 +401,46 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
|
||||||
|
|
||||||
void GLSpectrum::initializeGL()
|
void GLSpectrum::initializeGL()
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
initeglcompat();
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
QGLShader *vshader = new QGLShader(QGLShader::Vertex);
|
||||||
|
QGLShader *fshader = new QGLShader(QGLShader::Fragment);
|
||||||
|
|
||||||
|
const char *vsrc =
|
||||||
|
"attribute highp vec4 vertex;\n"
|
||||||
|
"attribute highp vec4 texCoord;\n"
|
||||||
|
"uniform mediump mat4 mvmatrix;\n"
|
||||||
|
"varying highp vec4 texc;\n"
|
||||||
|
"void main(void)\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = mvmatrix * vertex;\n"
|
||||||
|
" texc = texCoord;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
const char *fsrc =
|
||||||
|
"varying highp vec4 texc;\n"
|
||||||
|
"uniform sampler2D tex;\n"
|
||||||
|
"void main(void)\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = texture2D(tex, texc.st);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
vshader->compileSourceCode(vsrc);
|
||||||
|
fshader->compileSourceCode(fsrc);
|
||||||
|
|
||||||
|
shaderprog.addShader(vshader);
|
||||||
|
shaderprog.addShader(fshader);
|
||||||
|
shaderprog.link();
|
||||||
|
|
||||||
|
vertexAtt = shaderprog.attributeLocation("vertex");
|
||||||
|
texcoordAtt = shaderprog.attributeLocation("texCoord");
|
||||||
|
matrixUni = shaderprog.uniformLocation("mvmatrix");
|
||||||
|
texUni = shaderprog.uniformLocation("tex");
|
||||||
|
|
||||||
|
//init base matrix here
|
||||||
|
glScalef(2.0, -2.0, 1.0);
|
||||||
|
glTranslatef(-0.50, -0.5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLSpectrum::resizeGL(int width, int height)
|
void GLSpectrum::resizeGL(int width, int height)
|
||||||
|
@ -408,6 +450,24 @@ void GLSpectrum::resizeGL(int width, int height)
|
||||||
m_changesPending = true;
|
m_changesPending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLSpectrum::GLtexBox(){
|
||||||
|
GLfloat vertices[] = {0,0,0, 1,0,0, 0,1,0, 1,1,0};
|
||||||
|
GLfloat texcoords[] = {0, 0, 1, 0, 0, 1, 1, 1};
|
||||||
|
|
||||||
|
shaderprog.setUniformValue(matrixUni, getMV());
|
||||||
|
shaderprog.setUniformValue(texUni, 0);
|
||||||
|
shaderprog.setAttributeArray(vertexAtt, vertices, 3);
|
||||||
|
shaderprog.setAttributeArray(texcoordAtt, texcoords, 2);
|
||||||
|
|
||||||
|
shaderprog.enableAttributeArray(vertexAtt);
|
||||||
|
shaderprog.enableAttributeArray(texcoordAtt);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
shaderprog.disableAttributeArray(vertexAtt);
|
||||||
|
shaderprog.disableAttributeArray(texcoordAtt);
|
||||||
|
}
|
||||||
|
|
||||||
void GLSpectrum::paintGL()
|
void GLSpectrum::paintGL()
|
||||||
{
|
{
|
||||||
if(!m_mutex.tryLock(2))
|
if(!m_mutex.tryLock(2))
|
||||||
|
@ -421,13 +481,11 @@ void GLSpectrum::paintGL()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
glPushMatrix();
|
shaderprog.bind();
|
||||||
glScalef(2.0, -2.0, 1.0);
|
#if 1
|
||||||
glTranslatef(-0.50, -0.5, 0);
|
|
||||||
|
|
||||||
// paint waterfall
|
// paint waterfall
|
||||||
if(m_displayWaterfall) {
|
if(m_displayWaterfall) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -438,7 +496,7 @@ void GLSpectrum::paintGL()
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
for(int i = 0; i < m_waterfallBufferPos; i++) {
|
for(int i = 0; i < m_waterfallBufferPos; i++) {
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, m_waterfallTexturePos, m_fftSize, 1, GL_RGBA, GL_UNSIGNED_BYTE, m_waterfallBuffer->scanLine(i));
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, m_waterfallTexturePos, m_fftSize, 1, GL_RGBA, GL_UNSIGNED_BYTE, m_waterfallBuffer->scanLine(i));
|
||||||
m_waterfallTexturePos = (m_waterfallTexturePos + 1) % m_waterfallTextureHeight;
|
m_waterfallTexturePos = (m_waterfallTexturePos + 1) % m_waterfallTextureHeight;
|
||||||
|
@ -446,58 +504,28 @@ void GLSpectrum::paintGL()
|
||||||
m_waterfallBufferPos = 0;
|
m_waterfallBufferPos = 0;
|
||||||
float prop_y = m_waterfallTexturePos / (m_waterfallTextureHeight - 1.0);
|
float prop_y = m_waterfallTexturePos / (m_waterfallTextureHeight - 1.0);
|
||||||
float off = 1.0 / (m_waterfallTextureHeight - 1.0);
|
float off = 1.0 / (m_waterfallTextureHeight - 1.0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, prop_y + 1 - off);
|
|
||||||
glVertex2f(0, m_invertedWaterfall ? 0 : 1);
|
|
||||||
glTexCoord2f(1, prop_y + 1 - off);
|
|
||||||
glVertex2f(1, m_invertedWaterfall ? 0 : 1);
|
|
||||||
glTexCoord2f(1, prop_y);
|
|
||||||
glVertex2f(1, m_invertedWaterfall ? 1 : 0);
|
|
||||||
glTexCoord2f(0, prop_y);
|
|
||||||
glVertex2f(0, m_invertedWaterfall ? 1 : 0);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
// paint channels
|
GLfloat wavert1[] = {0,0,0, 1,0,0, 0,1,0, 1,1,0};
|
||||||
if(m_mouseInside) {
|
GLfloat wavert2[] = {0,1,0, 1,1,0, 0,0,0, 1,0,0};
|
||||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
GLfloat watexcoor[] = { 0, prop_y, 1, prop_y, 0, prop_y + 1 - off, 1, prop_y + 1 - off};
|
||||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
|
||||||
if(dv->m_channelMarker->getVisible()) {
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
|
|
||||||
glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw rect around
|
shaderprog.setUniformValue(matrixUni, getMV());
|
||||||
glEnable(GL_BLEND);
|
shaderprog.setUniformValue(texUni, 0);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
shaderprog.setAttributeArray(vertexAtt, m_invertedWaterfall ? wavert2 : wavert1, 3);
|
||||||
glLineWidth(1.0f);
|
shaderprog.setAttributeArray(texcoordAtt, watexcoor, 2);
|
||||||
glColor4f(1, 1, 1, 0.5);
|
|
||||||
glBegin(GL_LINE_LOOP);
|
shaderprog.enableAttributeArray(vertexAtt);
|
||||||
glVertex2f(1, 1);
|
shaderprog.enableAttributeArray(texcoordAtt);
|
||||||
glVertex2f(0, 1);
|
|
||||||
glVertex2f(0, 0);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glVertex2f(1, 0);
|
|
||||||
glEnd();
|
shaderprog.disableAttributeArray(vertexAtt);
|
||||||
glDisable(GL_BLEND);
|
shaderprog.disableAttributeArray(texcoordAtt);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
// paint histogram
|
// paint histogram
|
||||||
if(m_displayHistogram || m_displayMaxHold) {
|
if(m_displayHistogram || m_displayMaxHold) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -522,100 +550,40 @@ void GLSpectrum::paintGL()
|
||||||
glBindTexture(GL_TEXTURE_2D, m_histogramTexture);
|
glBindTexture(GL_TEXTURE_2D, m_histogramTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_fftSize, 100, GL_RGBA, GL_UNSIGNED_BYTE, m_histogramBuffer->scanLine(0));
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_fftSize, 100, GL_RGBA, GL_UNSIGNED_BYTE, m_histogramBuffer->scanLine(0));
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
// paint channels
|
GLtexBox();
|
||||||
if(m_mouseInside) {
|
|
||||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
|
||||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
|
||||||
if(dv->m_channelMarker->getVisible()) {
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
|
|
||||||
glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glColor3f(0.8f, 0.8f, 0.6f);
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(0.5, 0);
|
|
||||||
glVertex2f(0.5, 1);
|
|
||||||
glEnd();
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw rect around
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glLineWidth(1.0f);
|
|
||||||
glColor4f(1, 1, 1, 0.5);
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
// paint left scales (time and power)
|
// paint left scales (time and power)
|
||||||
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
|
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture);
|
glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0);
|
glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0);
|
||||||
glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1);
|
glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1);
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
GLtexBox();
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
// paint frequency scale
|
// paint frequency scale
|
||||||
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
|
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_frequencyTexture);
|
glBindTexture(GL_TEXTURE_2D, m_frequencyTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
@ -623,177 +591,12 @@ void GLSpectrum::paintGL()
|
||||||
glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0);
|
glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0);
|
||||||
glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1);
|
glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1);
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
GLtexBox();
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
// paint channels
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(m_glWaterfallRect.x(), m_glFrequencyScaleRect.y(), 0);
|
|
||||||
glScalef(m_glWaterfallRect.width(), m_glFrequencyScaleRect.height(), 1);
|
|
||||||
for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
|
|
||||||
ChannelMarkerState* dv = m_channelMarkerStates[i];
|
|
||||||
if(dv->m_channelMarker->getVisible()) {
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.5f);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
|
|
||||||
glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(1, 0);
|
|
||||||
glVertex2f(1, 1);
|
|
||||||
glVertex2f(0, 1);
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// paint max hold lines on top of histogram
|
shaderprog.release();
|
||||||
if(m_displayMaxHold) {
|
|
||||||
if(m_maxHold.size() < m_fftSize)
|
|
||||||
m_maxHold.resize(m_fftSize);
|
|
||||||
for(int i = 0; i < m_fftSize; i++) {
|
|
||||||
int j;
|
|
||||||
quint8* bs = m_histogram + i * 100;
|
|
||||||
for(j = 99; j > 1; j--) {
|
|
||||||
if(bs[j] > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// TODO: ((bs[j] * (float)j) + (bs[j + 1] * (float)(j + 1))) / (bs[j] + bs[j + 1])
|
|
||||||
j = j - 99;
|
|
||||||
m_maxHold[i] = (j * m_powerRange) / 99.0 + m_referenceLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0);
|
|
||||||
glScalef(m_glHistogramRect.width() / (float)(m_fftSize - 1), -m_glHistogramRect.height() / m_powerRange, 1);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
|
||||||
glLineWidth(1.0f);
|
|
||||||
glColor3f(1, 0, 0);
|
|
||||||
Real bottom = -m_powerRange;
|
|
||||||
glBegin(GL_LINE_STRIP);
|
|
||||||
for(int i = 0; i < m_fftSize; i++) {
|
|
||||||
Real v = m_maxHold[i] - m_referenceLevel;
|
|
||||||
if(v > 0)
|
|
||||||
v = 0;
|
|
||||||
else if(v < bottom)
|
|
||||||
v = bottom;
|
|
||||||
glVertex2f(i, v);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
glDisable(GL_LINE_SMOOTH);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
// paint waterfall grid
|
|
||||||
if(m_displayWaterfall && m_displayGrid) {
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glLineWidth(1.0f);
|
|
||||||
glColor4f(1, 1, 1, 0.05f);
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(m_glWaterfallRect.x(), m_glWaterfallRect.y(), 0);
|
|
||||||
glScalef(m_glWaterfallRect.width(), m_glWaterfallRect.height(), 1);
|
|
||||||
|
|
||||||
const ScaleEngine::TickList* tickList;
|
|
||||||
const ScaleEngine::Tick* tick;
|
|
||||||
|
|
||||||
tickList = &m_timeScale.getTickList();
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
|
||||||
tick = &(*tickList)[i];
|
|
||||||
if(tick->major) {
|
|
||||||
if(tick->textSize > 0) {
|
|
||||||
float y = tick->pos / m_timeScale.getSize();
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(0, y);
|
|
||||||
glVertex2f(1, y);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tickList = &m_frequencyScale.getTickList();
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
|
||||||
tick = &(*tickList)[i];
|
|
||||||
if(tick->major) {
|
|
||||||
if(tick->textSize > 0) {
|
|
||||||
float x = tick->pos / m_frequencyScale.getSize();
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(x, 0);
|
|
||||||
glVertex2f(x, 1);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
// paint histogram grid
|
|
||||||
if((m_displayHistogram || m_displayMaxHold) && (m_displayGrid)) {
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glLineWidth(1.0f);
|
|
||||||
glColor4f(1, 1, 1, 0.05f);
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0);
|
|
||||||
glScalef(m_glHistogramRect.width(), m_glHistogramRect.height(), 1);
|
|
||||||
|
|
||||||
const ScaleEngine::TickList* tickList;
|
|
||||||
const ScaleEngine::Tick* tick;
|
|
||||||
|
|
||||||
tickList = &m_powerScale.getTickList();
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
|
||||||
tick = &(*tickList)[i];
|
|
||||||
if(tick->major) {
|
|
||||||
if(tick->textSize > 0) {
|
|
||||||
float y = tick->pos / m_powerScale.getSize();
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(0, y);
|
|
||||||
glVertex2f(1, y);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tickList = &m_frequencyScale.getTickList();
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
|
||||||
tick = &(*tickList)[i];
|
|
||||||
if(tick->major) {
|
|
||||||
if(tick->textSize > 0) {
|
|
||||||
float x = tick->pos / m_frequencyScale.getSize();
|
|
||||||
glBegin(GL_LINE_LOOP);
|
|
||||||
glVertex2f(x, 0);
|
|
||||||
glVertex2f(x, 1);
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
|
||||||
m_refLevel(0),
|
m_refLevel(0),
|
||||||
m_powerRange(100),
|
m_powerRange(100),
|
||||||
m_decay(0),
|
m_decay(0),
|
||||||
m_displayWaterfall(false),
|
m_displayWaterfall(true),
|
||||||
m_invertedWaterfall(false),
|
m_invertedWaterfall(false),
|
||||||
m_displayMaxHold(true),
|
m_displayMaxHold(true),
|
||||||
m_displayHistogram(true),
|
m_displayHistogram(true),
|
||||||
|
@ -52,7 +52,7 @@ void GLSpectrumGUI::resetToDefaults()
|
||||||
m_refLevel = 0;
|
m_refLevel = 0;
|
||||||
m_powerRange = 100;
|
m_powerRange = 100;
|
||||||
m_decay = 0;
|
m_decay = 0;
|
||||||
m_displayWaterfall = false;
|
m_displayWaterfall = true;
|
||||||
m_invertedWaterfall = false;
|
m_invertedWaterfall = false;
|
||||||
m_displayMaxHold = true;
|
m_displayMaxHold = true;
|
||||||
m_displayHistogram = true;
|
m_displayHistogram = true;
|
||||||
|
|
|
@ -109,10 +109,10 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<!-- <property name="icon">
|
||||||
<iconset resource="../resources/res.qrc">
|
<iconset resource="../resources/res.qrc">
|
||||||
<normaloff>:/horizontal.png</normaloff>:/horizontal.png</iconset>
|
<normaloff>:/horizontal.png</normaloff>:/horizontal.png</iconset>
|
||||||
</property>
|
</property> -->
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>16</width>
|
<width>16</width>
|
||||||
|
@ -135,10 +135,10 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<!-- <property name="icon">
|
||||||
<iconset resource="../resources/res.qrc">
|
<iconset resource="../resources/res.qrc">
|
||||||
<normaloff>:/vertical.png</normaloff>:/vertical.png</iconset>
|
<normaloff>:/vertical.png</normaloff>:/vertical.png</iconset>
|
||||||
</property>
|
</property> -->
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
<width>16</width>
|
<width>16</width>
|
||||||
|
|
|
@ -64,30 +64,30 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
removeDockWidget(ui->inputDock);
|
removeDockWidget(ui->inputDock);
|
||||||
removeDockWidget(ui->processingDock);
|
removeDockWidget(ui->processingDock);
|
||||||
removeDockWidget(ui->presetDock);
|
removeDockWidget(ui->presetDock);
|
||||||
removeDockWidget(ui->channelDock);
|
// removeDockWidget(ui->channelDock);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock);
|
addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock);
|
addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock);
|
// addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, ui->channelDock);
|
// addDockWidget(Qt::RightDockWidgetArea, ui->channelDock);
|
||||||
ui->inputDock->show();
|
// ui->inputDock->show();
|
||||||
ui->processingDock->show();
|
// ui->processingDock->show();
|
||||||
ui->presetDock->show();
|
// ui->presetDock->show();
|
||||||
ui->channelDock->show();
|
//ui->channelDock->show();
|
||||||
|
|
||||||
ui->menu_Window->addAction(ui->inputDock->toggleViewAction());
|
ui->menu_Window->addAction(ui->inputDock->toggleViewAction());
|
||||||
ui->menu_Window->addAction(ui->processingDock->toggleViewAction());
|
ui->menu_Window->addAction(ui->processingDock->toggleViewAction());
|
||||||
ui->menu_Window->addAction(ui->presetDock->toggleViewAction());
|
// ui->menu_Window->addAction(ui->presetDock->toggleViewAction());
|
||||||
ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
|
//ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
|
||||||
|
|
||||||
connect(m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
connect(m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
m_statusTimer.start(500);
|
m_statusTimer.start(500);
|
||||||
|
|
||||||
m_pluginManager->loadPlugins();
|
m_pluginManager->loadPlugins();
|
||||||
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
||||||
m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
|
m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
|
||||||
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
||||||
|
|
||||||
m_dspEngine->start();
|
m_dspEngine->start();
|
||||||
|
|
||||||
|
@ -98,12 +98,12 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings
|
int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings
|
||||||
if(sampleSourceIndex >= 0) {
|
if(sampleSourceIndex >= 0) {
|
||||||
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
|
||||||
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
|
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
|
||||||
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings(m_settings.getCurrent());
|
loadSettings(m_settings.getCurrent());
|
||||||
|
|
||||||
|
@ -143,9 +143,9 @@ void MainWindow::addChannelCreateAction(QAction* action)
|
||||||
|
|
||||||
void MainWindow::addChannelRollup(QWidget* widget)
|
void MainWindow::addChannelRollup(QWidget* widget)
|
||||||
{
|
{
|
||||||
((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
|
// ((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
|
||||||
ui->channelDock->show();
|
// ui->channelDock->show();
|
||||||
ui->channelDock->raise();
|
// ui->channelDock->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addViewAction(QAction* action)
|
void MainWindow::addViewAction(QAction* action)
|
||||||
|
|
|
@ -318,7 +318,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="channelDock">
|
<!-- <widget class="QDockWidget" name="channelDock">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Channels</string>
|
<string>Channels</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -335,7 +335,7 @@
|
||||||
</property>
|
</property>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget> -->
|
||||||
<action name="action_Exit">
|
<action name="action_Exit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>E&xit</string>
|
<string>E&xit</string>
|
||||||
|
@ -444,12 +444,12 @@
|
||||||
<header>gui/glspectrumgui.h</header>
|
<header>gui/glspectrumgui.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<!-- <customwidget>
|
||||||
<class>ChannelWindow</class>
|
<class>ChannelWindow</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>gui/channelwindow.h</header>
|
<header>gui/channelwindow.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget> -->
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>presetTree</tabstop>
|
<tabstop>presetTree</tabstop>
|
||||||
|
|
|
@ -256,6 +256,9 @@ int PluginManager::selectSampleSource(const QString& source)
|
||||||
void PluginManager::loadPlugins(const QDir& dir)
|
void PluginManager::loadPlugins(const QDir& dir)
|
||||||
{
|
{
|
||||||
QDir pluginsDir(dir);
|
QDir pluginsDir(dir);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "libsdrange*.so" << "input*dll";
|
||||||
|
pluginsDir.setNameFilters(filters);
|
||||||
foreach(QString fileName, pluginsDir.entryList(QDir::Files)) {
|
foreach(QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||||
QPluginLoader* loader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName));
|
QPluginLoader* loader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||||
PluginInterface* plugin = qobject_cast<PluginInterface*>(loader->instance());
|
PluginInterface* plugin = qobject_cast<PluginInterface*>(loader->instance());
|
||||||
|
|
|
@ -13,9 +13,9 @@ void Preset::resetToDefaults()
|
||||||
m_centerFrequency = 0;
|
m_centerFrequency = 0;
|
||||||
m_spectrumConfig.clear();
|
m_spectrumConfig.clear();
|
||||||
m_scopeConfig.clear();
|
m_scopeConfig.clear();
|
||||||
m_dcOffsetCorrection = true;
|
m_dcOffsetCorrection = false;
|
||||||
m_iqImbalanceCorrection = true;
|
m_iqImbalanceCorrection = false;
|
||||||
m_showScope = true;
|
m_showScope = false;
|
||||||
m_layout.clear();
|
m_layout.clear();
|
||||||
m_spectrumConfig.clear();
|
m_spectrumConfig.clear();
|
||||||
m_channelConfigs.clear();
|
m_channelConfigs.clear();
|
||||||
|
|
|
@ -15,6 +15,7 @@ Settings::~Settings()
|
||||||
|
|
||||||
void Settings::load()
|
void Settings::load()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray())));
|
m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray())));
|
||||||
|
@ -31,10 +32,12 @@ void Settings::load()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::save() const
|
void Settings::save() const
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
s.setValue("preferences", qCompress(m_preferences.serialize()).toBase64());
|
s.setValue("preferences", qCompress(m_preferences.serialize()).toBase64());
|
||||||
|
@ -52,6 +55,7 @@ void Settings::save() const
|
||||||
s.setValue("data", qCompress(m_presets[i]->serialize()).toBase64());
|
s.setValue("data", qCompress(m_presets[i]->serialize()).toBase64());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::resetToDefaults()
|
void Settings::resetToDefaults()
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <QGLWidget>
|
||||||
|
#include <QMatrix4x4>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
static QMatrix4x4 mv[20];
|
||||||
|
static int pos=0;
|
||||||
|
static std::vector<QMatrix4x4*> stack;
|
||||||
|
|
||||||
|
void initeglcompat() {
|
||||||
|
mv[0].setToIdentity();
|
||||||
|
};
|
||||||
|
|
||||||
|
void glPushMatrix(){
|
||||||
|
pos++;
|
||||||
|
mv[pos] = mv[pos-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void glPopMatrix(){
|
||||||
|
if(pos >0){
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void glScalef(float x, float y, float z){
|
||||||
|
mv[pos].scale(x,y,z);
|
||||||
|
}
|
||||||
|
void glTranslatef(float x, float y, float z){
|
||||||
|
mv[pos].translate(x,y,z);
|
||||||
|
}
|
||||||
|
QMatrix4x4 getMV() {
|
||||||
|
return mv[pos];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue