From 70085588d68c8445df900a33b50b50e01c6acf32 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 10 Aug 2020 17:12:39 +1000 Subject: [PATCH 1/3] audiomonitor: fixed bug where audio was shown at normal speed even if playing faster --- app/widget/audiomonitor/audiomonitor.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/widget/audiomonitor/audiomonitor.cpp b/app/widget/audiomonitor/audiomonitor.cpp index 86b53a8df..a4cbd853d 100644 --- a/app/widget/audiomonitor/audiomonitor.cpp +++ b/app/widget/audiomonitor/audiomonitor.cpp @@ -275,23 +275,33 @@ void AudioMonitor::UpdateValuesFromFile(QVector& v) // Determines how many milliseconds have passed since last update qint64 current_time = QDateTime::currentMSecsSinceEpoch(); qint64 time_passed = current_time - last_time_; + int abs_speed = qAbs(playback_speed_); + + // Multiply by speed if the speed is not 1 + if (abs_speed != 1) { + time_passed *= abs_speed; + } // Convert ms to float seconds and determine how many bytes that is qint64 bytes_to_read = params_.time_to_bytes(static_cast(time_passed) * 0.001); if (playback_speed_ < 0) { + // If reversing, jump back by the amount of bytes we're going to read bytes_to_read = qMin(bytes_to_read, file_.pos()); file_.seek(file_.pos() - bytes_to_read); } + // Read bytes in from file QByteArray b = file_.read(bytes_to_read); if (playback_speed_ < 0) { + // If reversing, head back to where we were before the read so that the next read starts + // from where we left off file_.seek(file_.pos() - bytes_to_read); } - int abs_speed = qAbs(playback_speed_); + // If speed is not 1, transform it here if (abs_speed != 1) { int sample_sz = params_.samples_to_bytes(1); int in_nb_samples = params_.bytes_to_samples(b.size()); @@ -299,8 +309,8 @@ void AudioMonitor::UpdateValuesFromFile(QVector& v) QByteArray speed_adjusted(out_nb_samples * sample_sz, Qt::Uninitialized); for (int i=0;i Date: Mon, 10 Aug 2020 17:27:32 +1000 Subject: [PATCH 2/3] playbackcontrols: set play button policy to QPushButton default Minor cosmetic improvement. --- app/widget/playbackcontrols/playbackcontrols.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/widget/playbackcontrols/playbackcontrols.cpp b/app/widget/playbackcontrols/playbackcontrols.cpp index 4f1fdb64a..8a397786a 100644 --- a/app/widget/playbackcontrols/playbackcontrols.cpp +++ b/app/widget/playbackcontrols/playbackcontrols.cpp @@ -97,7 +97,10 @@ PlaybackControls::PlaybackControls(QWidget *parent) : // Default to showing play button playpause_stack_->setCurrentWidget(play_btn_); - playpause_stack_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); + + // Hack to conform the play/pause button size to the other buttons (QStackedWidget has a + // different size policy by default) + playpause_stack_->setSizePolicy(prev_frame_btn_->sizePolicy()); // Next Frame Button next_frame_btn_ = new QPushButton(); From ac649c86c58a1174a0b4fb02649d814f4b4e745e Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 10 Aug 2020 18:30:35 +1000 Subject: [PATCH 3/3] datatype: convert kInt type as a int64_t (which QVariant can't do automatically) --- app/node/input.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/node/input.cpp b/app/node/input.cpp index 890cb57e5..ecc4906d8 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -366,6 +366,8 @@ QString NodeInput::ValueToString(const DataType& data_type, const QVariant &valu || data_type == kBuffer) { // These data types need no XML representation return QString(); + } else if (data_type == kInt) { + return QString::number(value.value()); } else { if (value.canConvert()) { return value.toString(); @@ -397,6 +399,8 @@ QVariant NodeInput::StringToValue(const DataType& data_type, const QString &stri QStringList vals = string.split(':'); return QVariant::fromValue(Color(vals.at(0).toFloat(), vals.at(1).toFloat(), vals.at(2).toFloat(), vals.at(3).toFloat())); + } else if (data_type == kInt) { + return QVariant::fromValue(string.toLongLong()); } else if (data_type == kRational) { return QVariant::fromValue(rational::fromString(string)); } else {