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 <QApplication>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
@@ -6,6 +7,17 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
QApplication a(argc, 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 mainWindow;
|
||||||
mainWindow.show();
|
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 })
|
for (const auto samplerate : { 44100, 48000, 96000, 192000 })
|
||||||
m_ui.comboBoxSamplerate->addItem(tr("%0").arg(samplerate), samplerate);
|
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);
|
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;
|
auto buttonGroup = new QButtonGroup;
|
||||||
buttonGroup->setExclusive(true);
|
buttonGroup->setExclusive(true);
|
||||||
for (auto factor : { .5f, 1.f, 2.f, 4.f, 8.f })
|
for (auto factor : { .5f, 1.f, 2.f, 4.f, 8.f })
|
||||||
|
@@ -75,6 +75,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBoxGlow">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> glow</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65535</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@@ -26,12 +26,17 @@ float OsciWidget::factor() const
|
|||||||
return m_factor;
|
return m_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float OsciWidget::glow() const
|
||||||
|
{
|
||||||
|
return m_glow;
|
||||||
|
}
|
||||||
|
|
||||||
void OsciWidget::setFramerate(int framerate)
|
void OsciWidget::setFramerate(int framerate)
|
||||||
{
|
{
|
||||||
if (framerate == m_framerate)
|
if (framerate == m_framerate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "change framerate to" << framerate;
|
qDebug() << framerate;
|
||||||
|
|
||||||
m_framerate = framerate;
|
m_framerate = framerate;
|
||||||
|
|
||||||
@@ -43,16 +48,23 @@ void OsciWidget::setBlend(int blend)
|
|||||||
if (blend == m_blend)
|
if (blend == m_blend)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "change blend to" << blend;
|
qDebug() << blend;
|
||||||
|
|
||||||
m_blend = blend;
|
m_blend = blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsciWidget::setFactor(float factor)
|
void OsciWidget::setFactor(float factor)
|
||||||
{
|
{
|
||||||
|
qDebug() << factor;
|
||||||
m_factor = factor;
|
m_factor = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsciWidget::setGlow(float glow)
|
||||||
|
{
|
||||||
|
qDebug() << glow;
|
||||||
|
m_glow = glow;
|
||||||
|
}
|
||||||
|
|
||||||
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
||||||
{
|
{
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
@@ -69,19 +81,30 @@ void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
|||||||
|
|
||||||
for (auto i = begin; i < end; i++)
|
for (auto i = begin; i < end; i++)
|
||||||
{
|
{
|
||||||
const qreal x = (qreal(i->x) / std::numeric_limits<qint16>::max() / 2 * width() / 2 * m_factor);
|
const QPointF p{
|
||||||
const qreal y = (qreal(i->y) / std::numeric_limits<qint16>::max() / 2 * height() / 2 * m_factor);
|
float(i->x) / std::numeric_limits<qint16>::max() / 2,
|
||||||
const QPointF p{x, y};
|
float(-i->y) / std::numeric_limits<qint16>::max() / 2
|
||||||
|
};
|
||||||
|
|
||||||
if (Q_LIKELY(m_lastPoint.has_value()))
|
if (Q_LIKELY(m_lastPoint.has_value()))
|
||||||
{
|
{
|
||||||
auto speed = QLineF(*m_lastPoint, p).length();
|
const QLineF line(*m_lastPoint, p);
|
||||||
if (speed < 1)
|
|
||||||
speed = 1;
|
auto brightness = 1.f / line.length() / m_glow;
|
||||||
auto brightness = 1./speed;
|
if (line.length() == 0.f || brightness > 255.f)
|
||||||
|
brightness = 255.f;
|
||||||
|
|
||||||
painter.setOpacity(brightness);
|
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;
|
m_lastPoint = p;
|
||||||
|
@@ -24,6 +24,8 @@ public:
|
|||||||
int framerate() const;
|
int framerate() const;
|
||||||
int blend() const;
|
int blend() const;
|
||||||
float factor() const;
|
float factor() const;
|
||||||
|
float glow() const;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ public slots:
|
|||||||
void setFramerate(int framerate);
|
void setFramerate(int framerate);
|
||||||
void setBlend(int blend);
|
void setBlend(int blend);
|
||||||
void setFactor(float factor);
|
void setFactor(float factor);
|
||||||
|
void setGlow(float glow);
|
||||||
|
|
||||||
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
void renderSamples(const SamplePair *begin, const SamplePair *end);
|
||||||
|
|
||||||
@@ -46,8 +49,9 @@ private:
|
|||||||
|
|
||||||
int m_timerId{-1};
|
int m_timerId{-1};
|
||||||
int m_framerate{15};
|
int m_framerate{15};
|
||||||
int m_blend{190};
|
int m_blend{150};
|
||||||
float m_factor{4.f};
|
float m_factor{4.f};
|
||||||
|
float m_glow{512.f};
|
||||||
|
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user