removed reliance on Qt multimedia

This commit is contained in:
itsmattkc
2021-10-01 16:12:12 -07:00
parent 12a0c3a977
commit fbc5997d32
13 changed files with 111 additions and 95 deletions
+3 -3
View File
@@ -20,11 +20,11 @@
#include "audiomonitor.h"
#include <QAudio>
#include <QDebug>
#include <QPainter>
#include "audio/audiomanager.h"
#include "common/decibel.h"
#include "common/qtutils.h"
namespace olive {
@@ -170,7 +170,7 @@ void AudioMonitor::paintGL()
db_label = QStringLiteral("%1").arg(i);
}
qreal log_val = QAudio::convertVolume(i, QAudio::DecibelVolumeScale, QAudio::LogarithmicVolumeScale);
qreal log_val = Decibel::toLogarithmic(i);
QRect db_marking_rect = db_labels_rect;
db_marking_rect.adjust(0, db_labels_rect.height() - qRound(log_val * db_labels_rect.height()), 0, 0);
@@ -278,7 +278,7 @@ void AudioMonitor::paintGL()
}
// Convert val to logarithmic scale
vol = QAudio::convertVolume(vol, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale);
vol = Decibel::LinearToLogarithmic(vol);
meter_rect.adjust(0, 0, 0, -qRound(meter_rect.height() * vol));
p.drawRect(meter_rect);
+6 -22
View File
@@ -21,9 +21,10 @@
#include "floatslider.h"
#include <cmath>
#include <QAudio>
#include <QDebug>
#include "common/decibel.h"
namespace olive {
#define super DecimalSliderBase
@@ -91,7 +92,7 @@ QString FloatSlider::ValueToString(double val, FloatSlider::DisplayType display,
return tr("\xE2\x88\x9E");
}
val = LinearToDecibel(val);
val = Decibel::fromLinear(val);
break;
case kPercentage:
// Multiply value by 100 for user-friendly percentage
@@ -124,7 +125,7 @@ QVariant FloatSlider::StringToValue(const QString &s, bool *ok) const
if (valid) {
// Convert from decibel scale to linear decimal
return DecibelToLinear(decibels);
return Decibel::toLinear(decibels);
}
break;
@@ -159,9 +160,9 @@ QVariant FloatSlider::AdjustDragDistanceInternal(const QVariant &start, const do
break;
case kDecibel:
{
double current_db = LinearToDecibel(start.toDouble());
double current_db = Decibel::fromLinear(start.toDouble());
current_db += drag;
double adjusted_linear = DecibelToLinear(current_db);
double adjusted_linear = Decibel::toLinear(current_db);
return adjusted_linear;
}
@@ -177,21 +178,4 @@ void FloatSlider::ValueSignalEvent(const QVariant &value)
emit ValueChanged(value.toDouble());
}
double FloatSlider::LinearToDecibel(double linear)
{
return double(20.0) * std::log10(linear);
}
double FloatSlider::DecibelToLinear(double decibel)
{
double to_linear = std::pow(double(10.0), decibel / double(20.0));
// Minimum threshold that we figure is close enough to 0 that we may as well just return 0
if (to_linear < 0.000001) {
return 0;
} else {
return to_linear;
}
}
}
-4
View File
@@ -64,10 +64,6 @@ signals:
void ValueChanged(double);
private:
static double LinearToDecibel(double linear);
static double DecibelToLinear(double decibel);
DisplayType display_type_;
};
+3 -1
View File
@@ -48,7 +48,9 @@ namespace olive {
#define super TimeBasedWidget
QVector<ViewerWidget*> ViewerWidget::instances_;
const int ViewerWidget::kAudioPlaybackInterval = 2;
// NOTE: Hardcoded interval of size of audio chunk to render and send to the output at a time
const rational ViewerWidget::kAudioPlaybackInterval = rational(1, 8);
const int kMaxPreQueueSize = 8;
+2 -2
View File
@@ -219,7 +219,7 @@ private:
ViewerSizer* sizer_;
QAtomicInt playback_speed_;
int playback_speed_;
rational last_time_;
@@ -261,7 +261,7 @@ private:
PackedProcessor packed_processor_;
TempoProcessor tempo_processor_;
QByteArray prequeued_audio_;
static const int kAudioPlaybackInterval;
static const rational kAudioPlaybackInterval;
static QVector<ViewerWidget*> instances_;