]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Re-run IWYU, again with lots of manual cleanup.
[nageru] / mainwindow.cpp
index 0fc17b539fc4bad49795e163b8f2965bfc2610cf..3f0098be7a07d385e3326f1de0dbc184cf0e4dc6 100644 (file)
@@ -1,25 +1,39 @@
 #include "mainwindow.h"
-#include "window.h"
-#include <thread>
-#include <vector>
+
+#include <math.h>
+#include <stdio.h>
+#include <algorithm>
 #include <string>
-#include <QSignalMapper>
+#include <vector>
+#include <QBoxLayout>
+#include <QKeySequence>
+#include <QLabel>
 #include <QMetaType>
-#include <QShortcut>
+#include <QPushButton>
 #include <QResizeEvent>
+#include <QShortcut>
+#include <QSignalMapper>
+#include <QSize>
+#include <QString>
 
-#include "context.h"
+#include "glwidget.h"
+#include "lrameter.h"
 #include "mixer.h"
-
 #include "ui_mainwindow.h"
+#include "vumeter.h"
+
+class QResizeEvent;
 
 using namespace std;
 
 Q_DECLARE_METATYPE(std::vector<std::string>);
 
+MainWindow *global_mainwindow = nullptr;
+
 MainWindow::MainWindow()
        : ui(new Ui::MainWindow)
 {
+       global_mainwindow = this;
        ui->setupUi(this);
 
        ui->me_live->set_output(Mixer::OUTPUT_LIVE);
@@ -79,10 +93,6 @@ MainWindow::MainWindow()
        qRegisterMetaType<std::vector<std::string>>("std::vector<std::string>");
        connect(ui->preview1, SIGNAL(transition_names_updated(std::vector<std::string>)),
                this, SLOT(set_transition_names(std::vector<std::string>)));
-
-       // global_mixer does not exist yet, so need to delay the actual hookups.
-       global_vu_meter = ui->vu_meter;
-       global_peak_display = ui->peak_display;
 }
 
 void MainWindow::resizeEvent(QResizeEvent* event)
@@ -94,6 +104,23 @@ void MainWindow::resizeEvent(QResizeEvent* event)
        QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection);
 }
 
+void MainWindow::mixer_created(Mixer *mixer)
+{
+       mixer->set_audio_level_callback([this](float level_lufs, float peak_db, float global_level_lufs, float range_low_lufs, float range_high_lufs){
+               ui->vu_meter->set_level(level_lufs);
+               ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs);
+
+               char buf[256];
+               snprintf(buf, sizeof(buf), "%.1f", peak_db);
+               ui->peak_display->setText(buf);
+               if (peak_db > -0.1f) {  // -0.1 dBFS is EBU peak limit.
+                       ui->peak_display->setStyleSheet("QLabel { background-color: red; color: white; }");
+               } else {
+                       ui->peak_display->setStyleSheet("");
+               }
+       });
+}
+
 void MainWindow::relayout()
 {
        int width = size().width();