static std::once_flag flag;
std::call_once(flag, [this]{
global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()));
- global_mixer->set_audio_level_callback([this](float level_lufs, float peak_db){
- global_vu_meter->set_level(level_lufs);
-
- char buf[256];
- snprintf(buf, sizeof(buf), "%.1f", peak_db);
- global_peak_display->setText(buf);
- });
+ global_mainwindow->mixer_created(global_mixer);
global_mixer->start();
});
global_mixer->set_frame_ready_callback(output, [this]{
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);
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)
QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection);
}
+void MainWindow::mixer_created(Mixer *mixer)
+{
+ mixer->set_audio_level_callback([this](float level_lufs, float peak_db){
+ ui->vu_meter->set_level(level_lufs);
+
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%.1f", peak_db);
+ ui->peak_display->setText(buf);
+ });
+}
+
void MainWindow::relayout()
{
int width = size().width();
class MainWindow;
} // namespace Ui
+class Mixer;
class QPushButton;
class MainWindow : public QMainWindow
public:
MainWindow();
- void resizeEvent(QResizeEvent* event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void mixer_created(Mixer *mixer);
public slots:
void transition_clicked(int transition_number);
QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
};
+extern MainWindow *global_mainwindow;
+
#endif