removed reliance on Qt multimedia
This commit is contained in:
@@ -48,21 +48,6 @@ AudioManager *AudioManager::instance()
|
||||
|
||||
void AudioManager::RefreshDevices()
|
||||
{
|
||||
if (!is_refreshing_outputs_) {
|
||||
QFutureWatcher< QList<QAudioDeviceInfo> >* output_watcher = new QFutureWatcher< QList<QAudioDeviceInfo> >();
|
||||
connect(output_watcher, &QFutureWatcher< QList<QAudioDeviceInfo> >::finished, this, &AudioManager::OutputDevicesRefreshed);
|
||||
output_watcher->setFuture(QtConcurrent::run(QAudioDeviceInfo::availableDevices, QAudio::AudioOutput));
|
||||
|
||||
is_refreshing_outputs_ = true;
|
||||
}
|
||||
|
||||
if (!is_refreshing_inputs_) {
|
||||
QFutureWatcher< QList<QAudioDeviceInfo> >* input_watcher = new QFutureWatcher< QList<QAudioDeviceInfo> >();
|
||||
connect(input_watcher, &QFutureWatcher< QList<QAudioDeviceInfo> >::finished, this, &AudioManager::InputDevicesRefreshed);
|
||||
input_watcher->setFuture(QtConcurrent::run(QAudioDeviceInfo::availableDevices, QAudio::AudioInput));
|
||||
|
||||
is_refreshing_inputs_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioManager::IsRefreshingOutputs()
|
||||
@@ -209,16 +194,6 @@ void AudioManager::SetInputDevice(PaDeviceIndex device)
|
||||
input_device_ = device;
|
||||
}
|
||||
|
||||
const QList<QAudioDeviceInfo> &AudioManager::ListInputDevices()
|
||||
{
|
||||
return input_devices_;
|
||||
}
|
||||
|
||||
const QList<QAudioDeviceInfo> &AudioManager::ListOutputDevices()
|
||||
{
|
||||
return output_devices_;
|
||||
}
|
||||
|
||||
AudioManager::AudioManager() :
|
||||
is_refreshing_inputs_(false),
|
||||
is_refreshing_outputs_(false),
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define AUDIOMANAGER_H
|
||||
|
||||
#include <memory>
|
||||
#include <QAudioInput>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <QThread>
|
||||
#include <portaudio.h>
|
||||
@@ -68,9 +67,6 @@ public:
|
||||
|
||||
void SetInputDevice(PaDeviceIndex device);
|
||||
|
||||
const QList<QAudioDeviceInfo>& ListInputDevices();
|
||||
const QList<QAudioDeviceInfo>& ListOutputDevices();
|
||||
|
||||
signals:
|
||||
void OutputListReady();
|
||||
|
||||
@@ -87,9 +83,6 @@ private:
|
||||
|
||||
void CloseOutputStream();
|
||||
|
||||
QList<QAudioDeviceInfo> input_devices_;
|
||||
QList<QAudioDeviceInfo> output_devices_;
|
||||
|
||||
bool is_refreshing_inputs_;
|
||||
bool is_refreshing_outputs_;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ set(OLIVE_SOURCES
|
||||
common/crashpadutils.h
|
||||
common/debug.cpp
|
||||
common/debug.h
|
||||
common/decibel.h
|
||||
common/define.h
|
||||
common/ffmpegutils.cpp
|
||||
common/ffmpegutils.h
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DECIBEL_H
|
||||
#define DECIBEL_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <cmath>
|
||||
|
||||
namespace olive {
|
||||
|
||||
class Decibel
|
||||
{
|
||||
public:
|
||||
static double fromLinear(double linear)
|
||||
{
|
||||
return double(20.0) * std::log10(linear);
|
||||
}
|
||||
|
||||
static double toLinear(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;
|
||||
}
|
||||
}
|
||||
|
||||
static double fromLogarithmic(double logarithmic)
|
||||
{
|
||||
if (logarithmic < 0.001)
|
||||
return -200.0;
|
||||
else if (logarithmic > 0.99)
|
||||
return 0;
|
||||
else
|
||||
return 20.0 * std::log10(-std::log(1 - logarithmic) / LOG100);
|
||||
}
|
||||
|
||||
static double toLogarithmic(double decibel)
|
||||
{
|
||||
if (qFuzzyIsNull(decibel)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * LOG100);
|
||||
}
|
||||
}
|
||||
|
||||
static double LinearToLogarithmic(double linear)
|
||||
{
|
||||
return 1 - std::exp(-linear * LOG100);
|
||||
}
|
||||
|
||||
static double LogarithmicToLinear(double logarithmic)
|
||||
{
|
||||
if (logarithmic > 0.99) {
|
||||
return 1;
|
||||
} else {
|
||||
return -std::log(1 - logarithmic) / LOG100;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr double LOG100 = 4.60517018599;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DECIBEL_H
|
||||
@@ -179,20 +179,20 @@ void PreferencesAudioTab::RefreshDevices()
|
||||
|
||||
void PreferencesAudioTab::RetrieveOutputList()
|
||||
{
|
||||
PopulateComboBox(audio_output_devices_,
|
||||
/*PopulateComboBox(audio_output_devices_,
|
||||
AudioManager::instance()->IsRefreshingOutputs(),
|
||||
AudioManager::instance()->ListOutputDevices(),
|
||||
Config::Current()["AudioOutput"].toString());
|
||||
Config::Current()["AudioOutput"].toString());*/
|
||||
|
||||
UpdateRefreshButtonEnabled();
|
||||
}
|
||||
|
||||
void PreferencesAudioTab::RetrieveInputList()
|
||||
{
|
||||
PopulateComboBox(audio_input_devices_,
|
||||
/*PopulateComboBox(audio_input_devices_,
|
||||
AudioManager::instance()->IsRefreshingInputs(),
|
||||
AudioManager::instance()->ListInputDevices(),
|
||||
Config::Current()["AudioInput"].toString());
|
||||
Config::Current()["AudioInput"].toString());*/
|
||||
|
||||
UpdateRefreshButtonEnabled();
|
||||
}
|
||||
@@ -209,7 +209,7 @@ void PreferencesAudioTab::UpdateRefreshButtonEnabled()
|
||||
&& audio_input_devices_->isEnabled());
|
||||
}
|
||||
|
||||
void PreferencesAudioTab::PopulateComboBox(QComboBox *cb, bool still_refreshing, const QList<QAudioDeviceInfo> &list, const QString& preferred)
|
||||
/*void PreferencesAudioTab::PopulateComboBox(QComboBox *cb, bool still_refreshing, const QList<QAudioDeviceInfo> &list, const QString& preferred)
|
||||
{
|
||||
cb->clear();
|
||||
|
||||
@@ -237,6 +237,6 @@ void PreferencesAudioTab::PopulateComboBox(QComboBox *cb, bool still_refreshing,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef PREFERENCESAUDIOTAB_H
|
||||
#define PREFERENCESAUDIOTAB_H
|
||||
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -72,7 +71,7 @@ private:
|
||||
|
||||
void UpdateRefreshButtonEnabled();
|
||||
|
||||
static void PopulateComboBox(QComboBox* cb, bool still_refreshing, const QList<QAudioDeviceInfo>& list, const QString &preferred);
|
||||
//static void PopulateComboBox(QComboBox* cb, bool still_refreshing, const QList<QAudioDeviceInfo>& list, const QString &preferred);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -67,26 +67,6 @@ bool AudioParams::operator!=(const AudioParams &other) const
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
QAudioFormat::SampleType AudioParams::GetQtSampleType(AudioParams::Format format)
|
||||
{
|
||||
switch (format) {
|
||||
case kFormatUnsigned8:
|
||||
return QAudioFormat::UnSignedInt;
|
||||
case kFormatSigned16:
|
||||
case kFormatSigned32:
|
||||
case kFormatSigned64:
|
||||
return QAudioFormat::SignedInt;
|
||||
case kFormatFloat32:
|
||||
case kFormatFloat64:
|
||||
return QAudioFormat::Float;
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return QAudioFormat::Unknown;
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_bytes(const double &time) const
|
||||
{
|
||||
return time_to_bytes_per_channel(time) * channel_count();
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#ifndef AUDIOPARAMS_H
|
||||
#define AUDIOPARAMS_H
|
||||
|
||||
#include <QAudioFormat>
|
||||
#include <QtMath>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
@@ -184,8 +183,6 @@ public:
|
||||
bool operator==(const AudioParams& other) const;
|
||||
bool operator!=(const AudioParams& other) const;
|
||||
|
||||
static QAudioFormat::SampleType GetQtSampleType(Format format);
|
||||
|
||||
static const QVector<uint64_t> kSupportedChannelLayouts;
|
||||
static const QVector<int> kSupportedSampleRates;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,10 +64,6 @@ signals:
|
||||
void ValueChanged(double);
|
||||
|
||||
private:
|
||||
static double LinearToDecibel(double linear);
|
||||
|
||||
static double DecibelToLinear(double decibel);
|
||||
|
||||
DisplayType display_type_;
|
||||
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user