Auto stash before merge of "master" and "origin/master"
This commit is contained in:
12
main.cpp
12
main.cpp
@@ -1,4 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
@@ -6,6 +7,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
qSetMessagePattern(QStringLiteral("%{time dd.MM.yyyy HH:mm:ss.zzz} "
|
||||
"["
|
||||
"%{if-debug}D%{endif}"
|
||||
"%{if-info}I%{endif}"
|
||||
"%{if-warning}W%{endif}"
|
||||
"%{if-critical}C%{endif}"
|
||||
"%{if-fatal}F%{endif}"
|
||||
"] "
|
||||
"%{function}(): "
|
||||
"%{message}"));
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
|
@@ -30,6 +30,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui.comboBoxDevices->count())
|
||||
m_ui.comboBoxDevices->setCurrentIndex(m_audioDevices.count()-1);
|
||||
|
||||
for (const auto samplerate : { 44100, 48000, 96000, 192000 })
|
||||
m_ui.comboBoxSamplerate->addItem(tr("%0").arg(samplerate), samplerate);
|
||||
|
||||
@@ -48,6 +51,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
connect(m_ui.spinBoxBlend, qOverload<int>(&QSpinBox::valueChanged), m_ui.widget, &OsciWidget::setBlend);
|
||||
|
||||
m_ui.spinBoxGlow->setValue(m_ui.widget->glow());
|
||||
|
||||
connect(m_ui.spinBoxGlow, qOverload<int>(&QSpinBox::valueChanged), m_ui.widget, &OsciWidget::setGlow);
|
||||
|
||||
auto buttonGroup = new QButtonGroup;
|
||||
buttonGroup->setExclusive(true);
|
||||
for (auto factor : { .5f, 1.f, 2.f, 4.f, 8.f })
|
||||
|
@@ -75,6 +75,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxGlow">
|
||||
<property name="suffix">
|
||||
<string> glow</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@@ -26,12 +26,17 @@ float OsciWidget::factor() const
|
||||
return m_factor;
|
||||
}
|
||||
|
||||
float OsciWidget::glow() const
|
||||
{
|
||||
return m_glow;
|
||||
}
|
||||
|
||||
void OsciWidget::setFramerate(int framerate)
|
||||
{
|
||||
if (framerate == m_framerate)
|
||||
return;
|
||||
|
||||
qDebug() << "change framerate to" << framerate;
|
||||
qDebug() << framerate;
|
||||
|
||||
m_framerate = framerate;
|
||||
|
||||
@@ -43,16 +48,23 @@ void OsciWidget::setBlend(int blend)
|
||||
if (blend == m_blend)
|
||||
return;
|
||||
|
||||
qDebug() << "change blend to" << blend;
|
||||
qDebug() << blend;
|
||||
|
||||
m_blend = blend;
|
||||
}
|
||||
|
||||
void OsciWidget::setFactor(float factor)
|
||||
{
|
||||
qDebug() << factor;
|
||||
m_factor = factor;
|
||||
}
|
||||
|
||||
void OsciWidget::setGlow(float glow)
|
||||
{
|
||||
qDebug() << glow;
|
||||
m_glow = glow;
|
||||
}
|
||||
|
||||
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||
{
|
||||
QPainter painter;
|
||||
@@ -69,19 +81,30 @@ void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||
|
||||
for (auto i = begin; i < end; i++)
|
||||
{
|
||||
const qreal x = (qreal(i->x) / std::numeric_limits<qint16>::max() / 2 * width() / 2 * m_factor);
|
||||
const qreal y = (qreal(i->y) / std::numeric_limits<qint16>::max() / 2 * height() / 2 * m_factor);
|
||||
const QPointF p{x, y};
|
||||
const QPointF p{
|
||||
float(i->x) / std::numeric_limits<qint16>::max() / 2,
|
||||
float(-i->y) / std::numeric_limits<qint16>::max() / 2
|
||||
};
|
||||
|
||||
if (Q_LIKELY(m_lastPoint.has_value()))
|
||||
{
|
||||
auto speed = QLineF(*m_lastPoint, p).length();
|
||||
if (speed < 1)
|
||||
speed = 1;
|
||||
auto brightness = 1./speed;
|
||||
const QLineF line(*m_lastPoint, p);
|
||||
|
||||
auto brightness = 1.f / line.length() / m_glow;
|
||||
if (line.length() == 0.f || brightness > 255.f)
|
||||
brightness = 255.f;
|
||||
|
||||
painter.setOpacity(brightness);
|
||||
painter.drawLine(*m_lastPoint, p);
|
||||
|
||||
const auto pointToCoordinates = [this](const QPointF &point)
|
||||
{
|
||||
return QPoint{
|
||||
int((point.x() * width() / 2 * m_factor)),
|
||||
int((point.y() * height() / 2 * m_factor))
|
||||
};
|
||||
};
|
||||
|
||||
painter.drawLine(pointToCoordinates(*m_lastPoint), pointToCoordinates(p));
|
||||
}
|
||||
|
||||
m_lastPoint = p;
|
||||
|
@@ -24,6 +24,8 @@ public:
|
||||
int framerate() const;
|
||||
int blend() const;
|
||||
float factor() const;
|
||||
float glow() const;
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
@@ -31,6 +33,7 @@ public slots:
|
||||
void setFramerate(int framerate);
|
||||
void setBlend(int blend);
|
||||
void setFactor(float factor);
|
||||
void setGlow(float glow);
|
||||
|
||||
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
||||
|
||||
@@ -46,8 +49,9 @@ private:
|
||||
|
||||
int m_timerId{-1};
|
||||
int m_framerate{15};
|
||||
int m_blend{190};
|
||||
int m_blend{150};
|
||||
float m_factor{4.f};
|
||||
float m_glow{512.f};
|
||||
|
||||
QPixmap m_pixmap;
|
||||
|
||||
|
Reference in New Issue
Block a user