Compare commits

...

2 Commits
master ... gles

Author SHA1 Message Date
Hoernchen 834b192eb4 ffts 2014-08-05 01:49:47 +02:00
Hoernchen e30c4191d1 gles 2014-08-04 18:18:59 +02:00
21 changed files with 300 additions and 358 deletions

View File

@ -84,7 +84,7 @@ private:
typedef std::list<SampleSink*> SampleSinks;
SampleSinks m_sampleSinks;
AudioOutput m_audioOutput;
//AudioOutput m_audioOutput;
uint m_sampleRate;
quint64 m_centerFrequency;

View File

@ -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

View File

@ -1,7 +1,9 @@
#ifndef INCLUDE_INTERPOLATOR_H
#define INCLUDE_INTERPOLATOR_H
#if 0
#include <immintrin.h>
#endif
#include "dsp/dsptypes.h"
#include "util/export.h"
#include <stdio.h>
@ -55,7 +57,7 @@ private:
void doInterpolate(int phase, Complex* result)
{
#if 1
#if 0
// beware of the ringbuffer
if(m_ptr == 0) {
// only one straight block

View File

@ -21,6 +21,7 @@
#include <QGLWidget>
#include <QTimer>
#include <QMutex>
#include <QtOpenGL/qglshaderprogram.h>
#include "dsp/dsptypes.h"
#include "gui/scaleengine.h"
#include "dsp/channelmarker.h"
@ -131,12 +132,19 @@ private:
bool m_displayChanged;
QGLShaderProgram shaderprog;
int vertexAtt;
int texcoordAtt;
int matrixUni;
int texUni;
void updateWaterfall(const std::vector<Real>& spectrum);
void updateHistogram(const std::vector<Real>& spectrum);
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
void GLtexBox();
void stopDrag();
void applyChanges();

7
include/util/glmath.h Normal file
View File

@ -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();

View File

@ -1,6 +1,6 @@
#include "rtlsdrgui.h"
#include "ui_rtlsdrgui.h"
#include "plugin/pluginapi.h"
#include <plugin/pluginapi.h>
RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
QWidget(parent),

View File

@ -34,7 +34,7 @@ RTLSDRInput::Settings::Settings() :
void RTLSDRInput::Settings::resetToDefaults()
{
m_gain = 0;
m_decimation = 0;
m_decimation = 2;
}
QByteArray RTLSDRInput::Settings::serialize() const
@ -111,7 +111,7 @@ bool RTLSDRInput::startInput(int device)
qDebug("RTLSDRInput open: %s %s, SN: %s", vendor, product, 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));
goto failed;
}
@ -182,7 +182,7 @@ const QString& RTLSDRInput::getDeviceDescription() const
int RTLSDRInput::getSampleRate() const
{
return 2000000 / (1 << m_settings.m_decimation);
return 1000000 / (1 << m_settings.m_decimation);
}
quint64 RTLSDRInput::getCenterFrequency() const

View File

@ -325,7 +325,7 @@ DSPEngine::State DSPEngine::gotoIdle()
(*it)->stop();
m_sampleSource->stopInput();
m_deviceDescription.clear();
m_audioOutput.stop();
//m_audioOutput.stop();
m_sampleRate = 0;
return StIdle;
@ -357,7 +357,7 @@ DSPEngine::State DSPEngine::gotoRunning()
return gotoError("Could not start sample source");
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++)
(*it)->start();
m_sampleRate = 0; // make sure, report is sent
@ -489,10 +489,10 @@ void DSPEngine::handleMessages()
m_sampleSinks.remove(sink);
message->completed();
} else if(DSPAddAudioSource::match(message)) {
m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
//m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
message->completed();
} else if(DSPRemoveAudioSource::match(message)) {
m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
//m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
message->completed();
} else if(DSPConfigureCorrection::match(message)) {
DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message;

View File

@ -5,6 +5,9 @@
#ifdef USE_FFTW
#include "dsp/fftwengine.h"
#endif // USE_FFTW
#ifdef USE_FFTS
#include "dsp/fftsengine.h"
#endif // USE_FFTS
FFTEngine::~FFTEngine()
{
@ -20,7 +23,10 @@ FFTEngine* FFTEngine::create()
qDebug("FFT: using KissFFT engine");
return new KissEngine;
#endif // USE_KISSFFT
#ifdef USE_FFTS
qDebug("FFT: using FFTS engine");
return new FFTSEngine;
#endif // USE_FFTS
qCritical("FFT: no engine built");
return NULL;
}

View File

@ -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);
}

View File

@ -5,12 +5,11 @@
#define MAX_FFT_SIZE 4096
#ifdef _WIN32
double log2f(double n)
inline float log2f(float f)
{
return log(n) / log(2.0);
return logf(f) * (float) (1.0 / M_LN2);
}
#endif
SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
SampleSink(),

View File

@ -3,12 +3,13 @@
#include "gui/glscope.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) :
QGLWidget(parent),
@ -110,6 +111,7 @@ void GLScope::resizeGL(int width, int height)
void GLScope::paintGL()
{
#if 0
if(!m_mutex.tryLock(2))
return;
@ -172,7 +174,7 @@ void GLScope::paintGL()
glScalef(m_glScopeRect1.width(), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
//glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor4f(0, 1, 0, 0.3f);
glBegin(GL_LINE_LOOP);
@ -184,7 +186,7 @@ void GLScope::paintGL()
glVertex2f(0, m_triggerLevelLow);
glVertex2f(1, m_triggerLevelLow);
glEnd();
glDisable(GL_LINE_SMOOTH);
//glDisable(GL_LINE_SMOOTH);
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);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
//glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor4f(1, 1, 0, 0.4f);
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
@ -213,7 +215,7 @@ void GLScope::paintGL()
glVertex2f(i - start, v);
}
glEnd();
glDisable(GL_LINE_SMOOTH);
//glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
@ -259,7 +261,7 @@ void GLScope::paintGL()
glScalef(m_glScopeRect2.width(), -(m_glScopeRect2.height() / 2) * m_amp2, 1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
//glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor4f(0, 1, 0, 0.3f);
glBegin(GL_LINE_LOOP);
@ -271,7 +273,7 @@ void GLScope::paintGL()
glVertex2f(0, m_triggerLevelLow);
glVertex2f(1, m_triggerLevelLow);
glEnd();
glDisable(GL_LINE_SMOOTH);
//glDisable(GL_LINE_SMOOTH);
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);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
//glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor4f(1, 1, 0, 0.4f);
int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000;
@ -300,13 +302,14 @@ void GLScope::paintGL()
glVertex2f(i - start, v);
}
glEnd();
glDisable(GL_LINE_SMOOTH);
//glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
glPopMatrix();
m_dataChanged = false;
m_mutex.unlock();
#endif
}
void GLScope::mousePressEvent(QMouseEvent* event)

View File

@ -15,9 +15,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#if 0
#include <immintrin.h>
#endif
#include <QMouseEvent>
#include "gui/glspectrum.h"
#include "util/glmath.h"
GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
@ -315,7 +318,7 @@ void GLSpectrum::updateHistogram(const std::vector<Real>& spectrum)
m_histogramHoldoffCount = m_histogramHoldoffBase;
}
//#define NO_AVX
#define NO_AVX
#ifdef NO_AVX
for(int i = 0; i < m_fftSize; i++) {
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()
{
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)
@ -408,6 +450,24 @@ void GLSpectrum::resizeGL(int width, int height)
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()
{
if(!m_mutex.tryLock(2))
@ -421,13 +481,11 @@ void GLSpectrum::paintGL()
return;
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScalef(2.0, -2.0, 1.0);
glTranslatef(-0.50, -0.5, 0);
shaderprog.bind();
#if 1
// paint waterfall
if(m_displayWaterfall) {
glPushMatrix();
@ -438,7 +496,7 @@ void GLSpectrum::paintGL()
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_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++) {
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;
@ -446,58 +504,28 @@ void GLSpectrum::paintGL()
m_waterfallBufferPos = 0;
float prop_y = m_waterfallTexturePos / (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
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);
glPopMatrix();
}
}
}
GLfloat wavert1[] = {0,0,0, 1,0,0, 0,1,0, 1,1,0};
GLfloat wavert2[] = {0,1,0, 1,1,0, 0,0,0, 1,0,0};
GLfloat watexcoor[] = { 0, prop_y, 1, prop_y, 0, prop_y + 1 - off, 1, prop_y + 1 - off};
// 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);
shaderprog.setUniformValue(matrixUni, getMV());
shaderprog.setUniformValue(texUni, 0);
shaderprog.setAttributeArray(vertexAtt, m_invertedWaterfall ? wavert2 : wavert1, 3);
shaderprog.setAttributeArray(texcoordAtt, watexcoor, 2);
shaderprog.enableAttributeArray(vertexAtt);
shaderprog.enableAttributeArray(texcoordAtt);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
shaderprog.disableAttributeArray(vertexAtt);
shaderprog.disableAttributeArray(texcoordAtt);
glPopMatrix();
}
#endif
#if 1
// paint histogram
if(m_displayHistogram || m_displayMaxHold) {
glPushMatrix();
@ -522,100 +550,40 @@ void GLSpectrum::paintGL()
glBindTexture(GL_TEXTURE_2D, m_histogramTexture);
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_WRAP_T, GL_CLAMP);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//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));
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
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();
}
}
GLtexBox();
}
// 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();
}
#endif
#if 1
// paint left scales (time and power)
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture);
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_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();
glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0);
glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
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);
GLtexBox();
glPopMatrix();
}
#endif
#if 1
// paint frequency scale
if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) {
glBindTexture(GL_TEXTURE_2D, m_frequencyTexture);
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_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);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -623,177 +591,12 @@ void GLSpectrum::paintGL()
glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0);
glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1);
glEnable(GL_TEXTURE_2D);
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();
}
}
GLtexBox();
glPopMatrix();
glDisable(GL_BLEND);
}
// paint max hold lines on top of histogram
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();
#endif
shaderprog.release();
m_mutex.unlock();
}

View File

@ -17,7 +17,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
m_refLevel(0),
m_powerRange(100),
m_decay(0),
m_displayWaterfall(false),
m_displayWaterfall(true),
m_invertedWaterfall(false),
m_displayMaxHold(true),
m_displayHistogram(true),
@ -52,7 +52,7 @@ void GLSpectrumGUI::resetToDefaults()
m_refLevel = 0;
m_powerRange = 100;
m_decay = 0;
m_displayWaterfall = false;
m_displayWaterfall = true;
m_invertedWaterfall = false;
m_displayMaxHold = true;
m_displayHistogram = true;

View File

@ -109,10 +109,10 @@
<property name="text">
<string/>
</property>
<property name="icon">
<!-- <property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/horizontal.png</normaloff>:/horizontal.png</iconset>
</property>
</property> -->
<property name="iconSize">
<size>
<width>16</width>
@ -135,10 +135,10 @@
<property name="text">
<string/>
</property>
<property name="icon">
<!-- <property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/vertical.png</normaloff>:/vertical.png</iconset>
</property>
</property> -->
<property name="iconSize">
<size>
<width>16</width>

View File

@ -64,30 +64,30 @@ MainWindow::MainWindow(QWidget* parent) :
removeDockWidget(ui->inputDock);
removeDockWidget(ui->processingDock);
removeDockWidget(ui->presetDock);
removeDockWidget(ui->channelDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock);
addDockWidget(Qt::RightDockWidgetArea, ui->channelDock);
ui->inputDock->show();
ui->processingDock->show();
ui->presetDock->show();
ui->channelDock->show();
// removeDockWidget(ui->channelDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock);
// addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock);
// addDockWidget(Qt::RightDockWidgetArea, ui->channelDock);
// ui->inputDock->show();
// ui->processingDock->show();
// ui->presetDock->show();
//ui->channelDock->show();
ui->menu_Window->addAction(ui->inputDock->toggleViewAction());
ui->menu_Window->addAction(ui->processingDock->toggleViewAction());
ui->menu_Window->addAction(ui->presetDock->toggleViewAction());
ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
// ui->menu_Window->addAction(ui->presetDock->toggleViewAction());
//ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
connect(m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
m_pluginManager->loadPlugins();
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
m_pluginManager->loadPlugins();
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
m_dspEngine->start();
@ -98,12 +98,12 @@ MainWindow::MainWindow(QWidget* parent) :
loadSettings();
int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings
if(sampleSourceIndex >= 0) {
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
}
int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings
if(sampleSourceIndex >= 0) {
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
ui->sampleSource->setCurrentIndex(sampleSourceIndex);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
}
loadSettings(m_settings.getCurrent());
@ -143,9 +143,9 @@ void MainWindow::addChannelCreateAction(QAction* action)
void MainWindow::addChannelRollup(QWidget* widget)
{
((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
ui->channelDock->show();
ui->channelDock->raise();
// ((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
// ui->channelDock->show();
// ui->channelDock->raise();
}
void MainWindow::addViewAction(QAction* action)

View File

@ -318,7 +318,7 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="channelDock">
<!-- <widget class="QDockWidget" name="channelDock">
<property name="windowTitle">
<string>Channels</string>
</property>
@ -335,7 +335,7 @@
</property>
</layout>
</widget>
</widget>
</widget> -->
<action name="action_Exit">
<property name="text">
<string>E&amp;xit</string>
@ -444,12 +444,12 @@
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<!-- <customwidget>
<class>ChannelWindow</class>
<extends>QWidget</extends>
<header>gui/channelwindow.h</header>
<container>1</container>
</customwidget>
</customwidget> -->
</customwidgets>
<tabstops>
<tabstop>presetTree</tabstop>

View File

@ -256,6 +256,9 @@ int PluginManager::selectSampleSource(const QString& source)
void PluginManager::loadPlugins(const QDir& dir)
{
QDir pluginsDir(dir);
QStringList filters;
filters << "libsdrange*.so" << "input*dll";
pluginsDir.setNameFilters(filters);
foreach(QString fileName, pluginsDir.entryList(QDir::Files)) {
QPluginLoader* loader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName));
PluginInterface* plugin = qobject_cast<PluginInterface*>(loader->instance());

View File

@ -13,9 +13,9 @@ void Preset::resetToDefaults()
m_centerFrequency = 0;
m_spectrumConfig.clear();
m_scopeConfig.clear();
m_dcOffsetCorrection = true;
m_iqImbalanceCorrection = true;
m_showScope = true;
m_dcOffsetCorrection = false;
m_iqImbalanceCorrection = false;
m_showScope = false;
m_layout.clear();
m_spectrumConfig.clear();
m_channelConfigs.clear();

View File

@ -15,6 +15,7 @@ Settings::~Settings()
void Settings::load()
{
#if 0
QSettings s;
m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray())));
@ -31,10 +32,12 @@ void Settings::load()
s.endGroup();
}
}
#endif
}
void Settings::save() const
{
#if 0
QSettings s;
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.endGroup();
}
#endif
}
void Settings::resetToDefaults()

32
sdrbase/util/glmath.cpp Normal file
View File

@ -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];
}