Added debug controls for afterglow and lightspeed again
This commit is contained in:
@@ -2,11 +2,10 @@
|
|||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QStringBuilder>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QWidgetAction>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QSpinBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
@@ -43,13 +42,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// setting up menu File
|
// setting up menu File
|
||||||
connect(m_ui->actionStart, &QAction::triggered, this, &MainWindow::start);
|
connect(m_ui->actionStart, &QAction::triggered, this, &MainWindow::start);
|
||||||
connect(m_ui->actionStop, &QAction::triggered, this, &MainWindow::stop);
|
connect(m_ui->actionStop, &QAction::triggered, this, &MainWindow::stop);
|
||||||
m_ui->action_Quit->setShortcut(QKeySequence::Quit);
|
m_ui->actionQuit->setShortcut(QKeySequence::Quit);
|
||||||
|
|
||||||
// setting up menu Devices
|
// setting up menu Devices
|
||||||
for (const auto &device : m_audioDevices)
|
for (const auto &device : m_audioDevices)
|
||||||
{
|
{
|
||||||
auto name = device.deviceName();
|
auto name = device.deviceName();
|
||||||
const auto action = m_ui->menu_Device->addAction(name);
|
const auto action = m_ui->menuDevice->addAction(name);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
m_deviceGroup.addAction(action);
|
m_deviceGroup.addAction(action);
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// setting up menu Samplerates
|
// setting up menu Samplerates
|
||||||
for (const auto samplerate : samplerates)
|
for (const auto samplerate : samplerates)
|
||||||
{
|
{
|
||||||
auto action = m_ui->menu_Samplerate->addAction(tr("%0").arg(samplerate));
|
auto action = m_ui->menuSamplerate->addAction(tr("%0").arg(samplerate));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
m_samplerateGroup.addAction(action);
|
m_samplerateGroup.addAction(action);
|
||||||
}
|
}
|
||||||
@@ -71,7 +70,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// setting up menu Refreshrates
|
// setting up menu Refreshrates
|
||||||
for (const auto refreshrate : refreshrates)
|
for (const auto refreshrate : refreshrates)
|
||||||
{
|
{
|
||||||
auto action = m_ui->menu_Refreshrate->addAction(tr("%0FPS").arg(refreshrate));
|
auto action = m_ui->menuRefreshrate->addAction(tr("%0FPS").arg(refreshrate));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
m_refreshrateGroup.addAction(action);
|
m_refreshrateGroup.addAction(action);
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// setting up menu Zoom
|
// setting up menu Zoom
|
||||||
for (const auto zoomlevel : zoomlevels)
|
for (const auto zoomlevel : zoomlevels)
|
||||||
{
|
{
|
||||||
auto action = m_ui->menu_Zoom->addAction(tr("%0%").arg(zoomlevel));
|
auto action = m_ui->menuZoom->addAction(tr("%0%").arg(zoomlevel));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
m_zoomlevelsGroup.addAction(action);
|
m_zoomlevelsGroup.addAction(action);
|
||||||
}
|
}
|
||||||
@@ -100,6 +99,29 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
connect(&m_zoomlevelsGroup, &QActionGroup::triggered, this, &MainWindow::zoomChanged);
|
connect(&m_zoomlevelsGroup, &QActionGroup::triggered, this, &MainWindow::zoomChanged);
|
||||||
|
|
||||||
|
//setting up menu Debug
|
||||||
|
{
|
||||||
|
auto widgetAction = new QWidgetAction(this);
|
||||||
|
auto widget = new QWidget;
|
||||||
|
auto layout = new QFormLayout(widget);
|
||||||
|
{
|
||||||
|
auto input = new QSpinBox;
|
||||||
|
input->setRange(0, 255);
|
||||||
|
input->setValue(m_ui->widget->afterglow());
|
||||||
|
connect(input, qOverload<int>(&QSpinBox::valueChanged), m_ui->widget, &OsciWidget::setAfterglow);
|
||||||
|
layout->addRow(tr("Afterglow:"), input);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto input = new QSpinBox;
|
||||||
|
input->setRange(0, 255);
|
||||||
|
input->setValue(m_ui->widget->lightspeed());
|
||||||
|
connect(input, qOverload<int>(&QSpinBox::valueChanged), m_ui->widget, &OsciWidget::setLightspeed);
|
||||||
|
layout->addRow(tr("Lightspeed:"), input);
|
||||||
|
}
|
||||||
|
widgetAction->setDefaultWidget(widget);
|
||||||
|
m_ui->menuDebug->addAction(widgetAction);
|
||||||
|
}
|
||||||
|
|
||||||
// autostart
|
// autostart
|
||||||
if (m_audioDevices.isEmpty())
|
if (m_audioDevices.isEmpty())
|
||||||
{
|
{
|
||||||
|
@@ -23,43 +23,49 @@
|
|||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_File">
|
<widget class="QMenu" name="menuFile">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&File</string>
|
<string>&File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionStart"/>
|
<addaction name="actionStart"/>
|
||||||
<addaction name="actionStop"/>
|
<addaction name="actionStop"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_Quit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Device">
|
<widget class="QMenu" name="menuDevice">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Device</string>
|
<string>&Device</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Samplerate">
|
<widget class="QMenu" name="menuSamplerate">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Samplerate</string>
|
<string>&Samplerate</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Refreshrate">
|
<widget class="QMenu" name="menuRefreshrate">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Refreshrate</string>
|
<string>&Refreshrate</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Zoom">
|
<widget class="QMenu" name="menuZoom">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Zoom</string>
|
<string>&Zoom</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menu_File"/>
|
<widget class="QMenu" name="menuDebug">
|
||||||
<addaction name="menu_Device"/>
|
<property name="title">
|
||||||
<addaction name="menu_Samplerate"/>
|
<string>Debug</string>
|
||||||
<addaction name="menu_Refreshrate"/>
|
</property>
|
||||||
<addaction name="menu_Zoom"/>
|
</widget>
|
||||||
|
<addaction name="menuFile"/>
|
||||||
|
<addaction name="menuDevice"/>
|
||||||
|
<addaction name="menuSamplerate"/>
|
||||||
|
<addaction name="menuRefreshrate"/>
|
||||||
|
<addaction name="menuZoom"/>
|
||||||
|
<addaction name="menuDebug"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<action name="action_Quit">
|
<action name="actionQuit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Quit</string>
|
<string>&Quit</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -86,7 +92,7 @@
|
|||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>action_Quit</sender>
|
<sender>actionQuit</sender>
|
||||||
<signal>triggered()</signal>
|
<signal>triggered()</signal>
|
||||||
<receiver>MainWindow</receiver>
|
<receiver>MainWindow</receiver>
|
||||||
<slot>close()</slot>
|
<slot>close()</slot>
|
||||||
|
@@ -14,6 +14,11 @@ OsciWidget::OsciWidget(QWidget *parent) :
|
|||||||
m_statsTimer.start();
|
m_statsTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OsciWidget::lightspeed() const
|
||||||
|
{
|
||||||
|
return std::cbrt(m_lightspeed) * 20.f;
|
||||||
|
}
|
||||||
|
|
||||||
void OsciWidget::setFps(int fps)
|
void OsciWidget::setFps(int fps)
|
||||||
{
|
{
|
||||||
killTimer(m_redrawTimerId);
|
killTimer(m_redrawTimerId);
|
||||||
@@ -23,6 +28,12 @@ void OsciWidget::setFps(int fps)
|
|||||||
m_redrawTimerId = startTimer(1000/m_fps);
|
m_redrawTimerId = startTimer(1000/m_fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsciWidget::setLightspeed(int lightspeed) {
|
||||||
|
const auto temp = (float(lightspeed)/20.f);
|
||||||
|
m_lightspeed = temp*temp*temp;
|
||||||
|
qDebug() << m_lightspeed;
|
||||||
|
}
|
||||||
|
|
||||||
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||||
{
|
{
|
||||||
m_callbacksCounter++;
|
m_callbacksCounter++;
|
||||||
@@ -52,7 +63,7 @@ void OsciWidget::paintEvent(QPaintEvent *event)
|
|||||||
// darkening last frame
|
// darkening last frame
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
||||||
painter.setPen({});
|
painter.setPen({});
|
||||||
painter.setBrush(QColor(150,150,150 ));
|
painter.setBrush(QColor(m_afterglow, m_afterglow, m_afterglow));
|
||||||
painter.drawRect(m_pixmap.rect());
|
painter.drawRect(m_pixmap.rect());
|
||||||
|
|
||||||
// drawing new lines ontop
|
// drawing new lines ontop
|
||||||
@@ -80,7 +91,7 @@ void OsciWidget::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
const QLineF line(m_lastPoint, p);
|
const QLineF line(m_lastPoint, p);
|
||||||
|
|
||||||
painter.setOpacity(std::min(1.0, 1. / ((line.length() * 75) + 1)));
|
painter.setOpacity(std::min(1.0, 1. / ((line.length() * m_lightspeed) + 1)));
|
||||||
|
|
||||||
painter.drawLine(pointToCoordinates(m_lastPoint), pointToCoordinates(p));
|
painter.drawLine(pointToCoordinates(m_lastPoint), pointToCoordinates(p));
|
||||||
|
|
||||||
|
18
osciwidget.h
18
osciwidget.h
@@ -21,6 +21,8 @@ public:
|
|||||||
|
|
||||||
float factor() const { return m_factor; }
|
float factor() const { return m_factor; }
|
||||||
int fps() const { return m_fps; }
|
int fps() const { return m_fps; }
|
||||||
|
int afterglow() const { return m_afterglow; }
|
||||||
|
int lightspeed() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void statusUpdate(const QString &status);
|
void statusUpdate(const QString &status);
|
||||||
@@ -28,6 +30,8 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void setFactor(float factor) { m_factor = factor; }
|
void setFactor(float factor) { m_factor = factor; }
|
||||||
void setFps(int fps);
|
void setFps(int fps);
|
||||||
|
void setAfterglow(int afterglow) { m_afterglow = afterglow; }
|
||||||
|
void setLightspeed(int lightspeed);
|
||||||
|
|
||||||
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
||||||
|
|
||||||
@@ -36,17 +40,17 @@ protected:
|
|||||||
void timerEvent(QTimerEvent *event) override;
|
void timerEvent(QTimerEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_factor{2.f};
|
int m_redrawTimerId;
|
||||||
|
|
||||||
QPointF m_lastPoint;
|
QPointF m_lastPoint;
|
||||||
|
|
||||||
|
float m_factor{2.f};
|
||||||
|
int m_fps{15}, m_afterglow{175};
|
||||||
|
float m_lightspeed{35.f};
|
||||||
|
|
||||||
|
std::vector<SamplePair> m_buffer;
|
||||||
|
|
||||||
int m_frameCounter{0}, m_callbacksCounter{0};
|
int m_frameCounter{0}, m_callbacksCounter{0};
|
||||||
QElapsedTimer m_statsTimer;
|
QElapsedTimer m_statsTimer;
|
||||||
|
|
||||||
int m_fps{15};
|
|
||||||
int m_redrawTimerId;
|
|
||||||
|
|
||||||
std::vector<SamplePair> m_buffer;
|
|
||||||
|
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user