]> git.sesse.net Git - nageru/blob - mainwindow.cpp
Actually activate the faders.
[nageru] / mainwindow.cpp
1 #include "mainwindow.h"
2
3 #include <math.h>
4 #include <stdio.h>
5 #include <signal.h>
6 #include <algorithm>
7 #include <chrono>
8 #include <string>
9 #include <vector>
10 #include <QBoxLayout>
11 #include <QInputDialog>
12 #include <QKeySequence>
13 #include <QLabel>
14 #include <QMetaType>
15 #include <QPushButton>
16 #include <QResizeEvent>
17 #include <QShortcut>
18 #include <QSize>
19 #include <QString>
20
21 #include "aboutdialog.h"
22 #include "disk_space_estimator.h"
23 #include "flags.h"
24 #include "glwidget.h"
25 #include "lrameter.h"
26 #include "mixer.h"
27 #include "post_to_main_thread.h"
28 #include "ui_audio_miniview.h"
29 #include "ui_display.h"
30 #include "ui_mainwindow.h"
31 #include "vumeter.h"
32
33 class QResizeEvent;
34
35 using namespace std;
36 using namespace std::chrono;
37 using namespace std::placeholders;
38
39 Q_DECLARE_METATYPE(std::string);
40 Q_DECLARE_METATYPE(std::vector<std::string>);
41
42 MainWindow *global_mainwindow = nullptr;
43
44 namespace {
45
46 void schedule_cut_signal(int ignored)
47 {
48         global_mixer->schedule_cut();
49 }
50
51 void quit_signal(int ignored)
52 {
53         global_mainwindow->close();
54 }
55
56 constexpr unsigned DB_NO_FLAGS = 0x0;
57 constexpr unsigned DB_WITH_SIGN = 0x1;
58 constexpr unsigned DB_BARE = 0x2;
59
60 string format_db(double db, unsigned flags)
61 {
62         string text;
63         if (flags & DB_WITH_SIGN) {
64                 if (isfinite(db)) {
65                         char buf[256];
66                         snprintf(buf, sizeof(buf), "%+.1f", db);
67                         text = buf;
68                 } else if (db < 0.0) {
69                         text = "-∞";
70                 } else {
71                         // Should never happen, really.
72                         text = "+∞";
73                 }
74         } else {
75                 if (isfinite(db)) {
76                         char buf[256];
77                         snprintf(buf, sizeof(buf), "%.1f", db);
78                         text = buf;
79                 } else if (db < 0.0) {
80                         text = "-∞";
81                 } else {
82                         // Should never happen, really.
83                         text = "∞";
84                 }
85         }
86         if (!(flags & DB_BARE)) {
87                 text += " dB";
88         }
89         return text;
90 }
91
92 }  // namespace
93
94 MainWindow::MainWindow()
95         : ui(new Ui::MainWindow)
96 {
97         global_mainwindow = this;
98         ui->setupUi(this);
99
100         global_disk_space_estimator = new DiskSpaceEstimator(bind(&MainWindow::report_disk_space, this, _1, _2));
101         disk_free_label = new QLabel(this);
102         disk_free_label->setStyleSheet("QLabel {padding-right: 5px;}");
103         ui->menuBar->setCornerWidget(disk_free_label);
104
105         ui->me_live->set_output(Mixer::OUTPUT_LIVE);
106         ui->me_preview->set_output(Mixer::OUTPUT_PREVIEW);
107
108         // The menus.
109         connect(ui->cut_action, &QAction::triggered, this, &MainWindow::cut_triggered);
110         connect(ui->exit_action, &QAction::triggered, this, &MainWindow::exit_triggered);
111         connect(ui->about_action, &QAction::triggered, this, &MainWindow::about_triggered);
112
113         if (global_flags.x264_video_to_http) {
114                 connect(ui->x264_bitrate_action, &QAction::triggered, this, &MainWindow::x264_bitrate_triggered);
115         } else {
116                 ui->x264_bitrate_action->setEnabled(false);
117         }
118
119         // Hook up the transition buttons. (Keyboard shortcuts are set in set_transition_names().)
120         // TODO: Make them dynamic.
121         connect(ui->transition_btn1, &QPushButton::clicked, bind(&MainWindow::transition_clicked, this, 0));
122         connect(ui->transition_btn2, &QPushButton::clicked, bind(&MainWindow::transition_clicked, this, 1));
123         connect(ui->transition_btn3, &QPushButton::clicked, bind(&MainWindow::transition_clicked, this, 2));
124
125         // Aiee...
126         transition_btn1 = ui->transition_btn1;
127         transition_btn2 = ui->transition_btn2;
128         transition_btn3 = ui->transition_btn3;
129         qRegisterMetaType<string>("std::string");
130         qRegisterMetaType<vector<string>>("std::vector<std::string>");
131         connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names);
132         qRegisterMetaType<Mixer::Output>("Mixer::Output");
133
134         last_audio_level_callback = steady_clock::now() - seconds(1);
135 }
136
137 void MainWindow::resizeEvent(QResizeEvent* event)
138 {
139         QMainWindow::resizeEvent(event);
140
141         // Ask for a relayout, but only after the event loop is done doing relayout
142         // on everything else.
143         QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection);
144 }
145
146 void MainWindow::mixer_created(Mixer *mixer)
147 {
148         // Make the previews.
149         unsigned num_previews = mixer->get_num_channels();
150
151         for (unsigned i = 0; i < num_previews; ++i) {
152                 Mixer::Output output = Mixer::Output(Mixer::OUTPUT_INPUT0 + i);
153
154                 QWidget *preview = new QWidget(this);
155                 Ui::Display *ui_display = new Ui::Display;
156                 ui_display->setupUi(preview);
157                 ui_display->label->setText(mixer->get_channel_name(output).c_str());
158                 ui_display->display->set_output(output);
159                 ui->preview_displays->insertWidget(previews.size(), preview, 1);
160                 previews.push_back(ui_display);
161
162                 // Hook up the click.
163                 connect(ui_display->display, &GLWidget::clicked, bind(&MainWindow::channel_clicked, this, i));
164
165                 // Let the theme update the text whenever the resolution or color changed.
166                 connect(ui_display->display, &GLWidget::name_updated, this, &MainWindow::update_channel_name);
167                 connect(ui_display->display, &GLWidget::color_updated, this, &MainWindow::update_channel_color);
168
169                 // Hook up the keyboard key.
170                 QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this);
171                 connect(shortcut, &QShortcut::activated, bind(&MainWindow::channel_clicked, this, i));
172
173                 // Hook up the white balance button (irrelevant if invisible).
174                 ui_display->wb_button->setVisible(mixer->get_supports_set_wb(output));
175                 connect(ui_display->wb_button, &QPushButton::clicked, bind(&MainWindow::wb_button_clicked, this, i));
176         }
177
178         // Audio miniview: Make some channels!
179         for (unsigned i = 0; i < num_previews; ++i) {
180                 Mixer::Output output = Mixer::Output(Mixer::OUTPUT_INPUT0 + i);
181
182                 QWidget *channel = new QWidget(this);
183                 Ui::AudioMiniView *ui_audio_miniview = new Ui::AudioMiniView;
184                 ui_audio_miniview->setupUi(channel);
185                 ui_audio_miniview->channel_desc_label->setFullText(
186                         QString::fromStdString(mixer->get_channel_name(output)));
187                 ui->faders->addWidget(channel);
188
189                 connect(ui_audio_miniview->fader, &QAbstractSlider::valueChanged,
190                         bind(&MainWindow::mini_fader_changed, this, ui_audio_miniview, i, _1));
191         }
192
193         // TODO: Fetch all of the values these for completeness,
194         // not just the enable knobs implied by flags.
195         ui->locut_enabled->setChecked(global_mixer->get_audio_mixer()->get_locut_enabled());
196         ui->gainstaging_knob->setValue(global_mixer->get_audio_mixer()->get_gain_staging_db());
197         ui->gainstaging_auto_checkbox->setChecked(global_mixer->get_audio_mixer()->get_gain_staging_auto());
198         ui->compressor_enabled->setChecked(global_mixer->get_audio_mixer()->get_compressor_enabled());
199         ui->limiter_enabled->setChecked(global_mixer->get_audio_mixer()->get_limiter_enabled());
200         ui->makeup_gain_auto_checkbox->setChecked(global_mixer->get_audio_mixer()->get_final_makeup_gain_auto());
201
202         ui->limiter_threshold_db_display->setText(
203                 QString::fromStdString(format_db(mixer->get_audio_mixer()->get_limiter_threshold_dbfs(), DB_WITH_SIGN)));
204         ui->compressor_threshold_db_display->setText(
205                 QString::fromStdString(format_db(mixer->get_audio_mixer()->get_compressor_threshold_dbfs(), DB_WITH_SIGN)));
206
207         connect(ui->locut_cutoff_knob, &QDial::valueChanged, this, &MainWindow::cutoff_knob_changed);
208         cutoff_knob_changed(ui->locut_cutoff_knob->value());
209         connect(ui->locut_enabled, &QCheckBox::stateChanged, [this](int state){
210                 global_mixer->get_audio_mixer()->set_locut_enabled(state == Qt::Checked);
211         });
212
213         connect(ui->gainstaging_knob, &QAbstractSlider::valueChanged, this, &MainWindow::gain_staging_knob_changed);
214         connect(ui->gainstaging_auto_checkbox, &QCheckBox::stateChanged, [this](int state){
215                 global_mixer->get_audio_mixer()->set_gain_staging_auto(state == Qt::Checked);
216         });
217         connect(ui->makeup_gain_knob, &QAbstractSlider::valueChanged, this, &MainWindow::final_makeup_gain_knob_changed);
218         connect(ui->makeup_gain_auto_checkbox, &QCheckBox::stateChanged, [this](int state){
219                 global_mixer->get_audio_mixer()->set_final_makeup_gain_auto(state == Qt::Checked);
220         });
221
222         connect(ui->limiter_threshold_knob, &QDial::valueChanged, this, &MainWindow::limiter_threshold_knob_changed);
223         connect(ui->compressor_threshold_knob, &QDial::valueChanged, this, &MainWindow::compressor_threshold_knob_changed);
224         connect(ui->limiter_enabled, &QCheckBox::stateChanged, [this](int state){
225                 global_mixer->get_audio_mixer()->set_limiter_enabled(state == Qt::Checked);
226         });
227         connect(ui->compressor_enabled, &QCheckBox::stateChanged, [this](int state){
228                 global_mixer->get_audio_mixer()->set_compressor_enabled(state == Qt::Checked);
229         });
230         connect(ui->reset_meters_button, &QPushButton::clicked, this, &MainWindow::reset_meters_button_clicked);
231         mixer->set_audio_level_callback(bind(&MainWindow::audio_level_callback, this, _1, _2, _3, _4, _5, _6, _7, _8));
232
233         struct sigaction act;
234         memset(&act, 0, sizeof(act));
235         act.sa_handler = schedule_cut_signal;
236         act.sa_flags = SA_RESTART;
237         sigaction(SIGHUP, &act, nullptr);
238
239         // Mostly for debugging. Don't override SIGINT, that's so evil if
240         // shutdown isn't instant.
241         memset(&act, 0, sizeof(act));
242         act.sa_handler = quit_signal;
243         act.sa_flags = SA_RESTART;
244         sigaction(SIGUSR1, &act, nullptr);
245 }
246
247 void MainWindow::mixer_shutting_down()
248 {
249         ui->me_live->clean_context();
250         ui->me_preview->clean_context();
251         for (Ui::Display *display : previews) {
252                 display->display->clean_context();
253         }
254 }
255
256 void MainWindow::cut_triggered()
257 {
258         global_mixer->schedule_cut();
259 }
260
261 void MainWindow::x264_bitrate_triggered()
262 {
263         bool ok;
264         int new_bitrate = QInputDialog::getInt(this, "Change x264 bitrate", "Choose new bitrate for x264 HTTP output (from 100–100,000 kbit/sec):", global_flags.x264_bitrate, /*min=*/100, /*max=*/100000, /*step=*/100, &ok);
265         if (ok && new_bitrate >= 100 && new_bitrate <= 100000) {
266                 global_flags.x264_bitrate = new_bitrate;
267                 global_mixer->change_x264_bitrate(new_bitrate);
268         }
269 }
270
271 void MainWindow::exit_triggered()
272 {
273         close();
274 }
275
276 void MainWindow::about_triggered()
277 {
278         AboutDialog().exec();
279 }
280
281 void MainWindow::gain_staging_knob_changed(int value)
282 {
283         ui->gainstaging_auto_checkbox->setCheckState(Qt::Unchecked);
284
285         float gain_db = value * 0.1f;
286         global_mixer->get_audio_mixer()->set_gain_staging_db(gain_db);
287
288         // The label will be updated by the audio level callback.
289 }
290
291 void MainWindow::final_makeup_gain_knob_changed(int value)
292 {
293         ui->makeup_gain_auto_checkbox->setCheckState(Qt::Unchecked);
294
295         float gain_db = value * 0.1f;
296         global_mixer->get_audio_mixer()->set_final_makeup_gain_db(gain_db);
297
298         // The label will be updated by the audio level callback.
299 }
300
301 void MainWindow::cutoff_knob_changed(int value)
302 {
303         float octaves = value * 0.1f;
304         float cutoff_hz = 20.0 * pow(2.0, octaves);
305         global_mixer->get_audio_mixer()->set_locut_cutoff(cutoff_hz);
306
307         char buf[256];
308         snprintf(buf, sizeof(buf), "%ld Hz", lrintf(cutoff_hz));
309         ui->locut_cutoff_display->setText(buf);
310 }
311
312 void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left)
313 {
314         char time_str[256];
315         if (estimated_seconds_left < 60.0) {
316                 strcpy(time_str, "<font color=\"red\">Less than a minute</font>");
317         } else if (estimated_seconds_left < 1800.0) {  // Less than half an hour: Xm Ys (red).
318                 int s = lrintf(estimated_seconds_left);
319                 int m = s / 60;
320                 s %= 60;
321                 snprintf(time_str, sizeof(time_str), "<font color=\"red\">%dm %ds</font>", m, s);
322         } else if (estimated_seconds_left < 3600.0) {  // Less than an hour: Xm.
323                 int m = lrintf(estimated_seconds_left / 60.0);
324                 snprintf(time_str, sizeof(time_str), "%dm", m);
325         } else if (estimated_seconds_left < 36000.0) {  // Less than ten hours: Xh Ym.
326                 int m = lrintf(estimated_seconds_left / 60.0);
327                 int h = m / 60;
328                 m %= 60;
329                 snprintf(time_str, sizeof(time_str), "%dh %dm", h, m);
330         } else {  // More than ten hours: Xh.
331                 int h = lrintf(estimated_seconds_left / 3600.0);
332                 snprintf(time_str, sizeof(time_str), "%dh", h);
333         }
334         char buf[256];
335         snprintf(buf, sizeof(buf), "Disk free: %'.0f MB (approx. %s)", free_bytes / 1048576.0, time_str);
336
337         std::string label = buf;
338
339         post_to_main_thread([this, label]{
340                 disk_free_label->setText(QString::fromStdString(label));
341                 ui->menuBar->setCornerWidget(disk_free_label);  // Need to set this again for the sizing to get right.
342         });
343 }
344
345 void MainWindow::limiter_threshold_knob_changed(int value)
346 {
347         float threshold_dbfs = value * 0.1f;
348         global_mixer->get_audio_mixer()->set_limiter_threshold_dbfs(threshold_dbfs);
349         ui->limiter_threshold_db_display->setText(
350                 QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
351 }
352
353 void MainWindow::compressor_threshold_knob_changed(int value)
354 {
355         float threshold_dbfs = value * 0.1f;
356         global_mixer->get_audio_mixer()->set_compressor_threshold_dbfs(threshold_dbfs);
357         ui->compressor_threshold_db_display->setText(
358                 QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
359 }
360
361 void MainWindow::mini_fader_changed(Ui::AudioMiniView *ui, int channel, int value)
362 {
363         float volume_db = value * 0.1f;
364
365         char buf[256];
366         snprintf(buf, sizeof(buf), "%+.1f dB", volume_db);
367         ui->fader_label->setText(buf);
368
369         global_mixer->get_audio_mixer()->set_fader_volume(channel, volume_db);
370 }
371
372 void MainWindow::reset_meters_button_clicked()
373 {
374         global_mixer->reset_meters();
375         ui->peak_display->setText(QString::fromStdString(format_db(-HUGE_VAL, DB_WITH_SIGN | DB_BARE)));
376         ui->peak_display->setStyleSheet("");
377 }
378
379 void MainWindow::audio_level_callback(float level_lufs, float peak_db, float global_level_lufs,
380                                       float range_low_lufs, float range_high_lufs,
381                                       float gain_staging_db, float final_makeup_gain_db,
382                                       float correlation)
383 {
384         steady_clock::time_point now = steady_clock::now();
385
386         // The meters are somewhat inefficient to update. Only update them
387         // every 100 ms or so (we get updates every 5–20 ms).
388         double last_update_age = duration<double>(now - last_audio_level_callback).count();
389         if (last_update_age < 0.100) {
390                 return;
391         }
392         last_audio_level_callback = now;
393
394         post_to_main_thread([=]() {
395                 ui->vu_meter->set_level(level_lufs);
396                 ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs);
397                 ui->correlation_meter->set_correlation(correlation);
398
399                 ui->peak_display->setText(QString::fromStdString(format_db(peak_db, DB_BARE)));
400                 if (peak_db > -0.1f) {  // -0.1 dBFS is EBU peak limit.
401                         ui->peak_display->setStyleSheet("QLabel { background-color: red; color: white; }");
402                 } else {
403                         ui->peak_display->setStyleSheet("");
404                 }
405
406                 ui->gainstaging_knob->blockSignals(true);
407                 ui->gainstaging_knob->setValue(lrintf(gain_staging_db * 10.0f));
408                 ui->gainstaging_knob->blockSignals(false);
409                 ui->gainstaging_db_display->setText(
410                         QString::fromStdString(format_db(gain_staging_db, DB_WITH_SIGN)));
411
412                 ui->makeup_gain_knob->blockSignals(true);
413                 ui->makeup_gain_knob->setValue(lrintf(final_makeup_gain_db * 10.0f));
414                 ui->makeup_gain_knob->blockSignals(false);
415                 ui->makeup_gain_db_display->setText(
416                         QString::fromStdString(format_db(final_makeup_gain_db, DB_WITH_SIGN)));
417         });
418 }
419
420 void MainWindow::relayout()
421 {
422         int height = ui->vertical_layout->geometry().height();
423
424         double remaining_height = height;
425
426         // Allocate the height; the most important part is to keep the main displays
427         // at 16:9 if at all possible.
428         double me_width = ui->me_preview->width();
429         double me_height = me_width * 9.0 / 16.0 + ui->label_preview->height() + ui->preview_vertical_layout->spacing();
430
431         // TODO: Scale the widths when we need to do this.
432         if (me_height / double(height) > 0.8) {
433                 me_height = height * 0.8;
434         }
435         remaining_height -= me_height + ui->vertical_layout->spacing();
436
437         // Space between the M/E displays and the audio strip.
438         remaining_height -= ui->vertical_layout->spacing();
439
440         // The previews will be constrained by the remaining height, and the width.
441         double preview_label_height = previews[0]->title_bar->geometry().height() +
442                 previews[0]->main_vertical_layout->spacing();
443         int preview_total_width = ui->preview_displays->geometry().width() - (previews.size() - 1) * ui->preview_displays->spacing();
444         double preview_height = min(remaining_height - preview_label_height, (preview_total_width / double(previews.size())) * 9.0 / 16.0);
445         remaining_height -= preview_height + preview_label_height + ui->vertical_layout->spacing();
446
447         ui->vertical_layout->setStretch(0, lrintf(me_height));
448         ui->vertical_layout->setStretch(1, lrintf(remaining_height));  // Audio strip.
449         ui->vertical_layout->setStretch(2, lrintf(preview_height + preview_label_height));
450
451         // Set the widths for the previews.
452         double preview_width = preview_height * 16.0 / 9.0;
453         for (unsigned i = 0; i < previews.size(); ++i) {
454                 ui->preview_displays->setStretch(i, lrintf(preview_width));
455         }
456
457         // The preview horizontal spacer.
458         double remaining_preview_width = preview_total_width - previews.size() * preview_width;
459         ui->preview_displays->setStretch(previews.size(), lrintf(remaining_preview_width));
460 }
461
462 void MainWindow::set_transition_names(vector<string> transition_names)
463 {
464         if (transition_names.size() < 1 || transition_names[0].empty()) {
465                 transition_btn1->setText(QString(""));
466         } else {
467                 transition_btn1->setText(QString::fromStdString(transition_names[0] + " (J)"));
468                 ui->transition_btn1->setShortcut(QKeySequence("J"));
469         }
470         if (transition_names.size() < 2 || transition_names[1].empty()) {
471                 transition_btn2->setText(QString(""));
472         } else {
473                 transition_btn2->setText(QString::fromStdString(transition_names[1] + " (K)"));
474                 ui->transition_btn2->setShortcut(QKeySequence("K"));
475         }
476         if (transition_names.size() < 3 || transition_names[2].empty()) {
477                 transition_btn3->setText(QString(""));
478         } else {
479                 transition_btn3->setText(QString::fromStdString(transition_names[2] + " (L)"));
480                 ui->transition_btn3->setShortcut(QKeySequence("L"));
481         }
482 }
483
484 void MainWindow::update_channel_name(Mixer::Output output, const string &name)
485 {
486         if (output >= Mixer::OUTPUT_INPUT0) {
487                 unsigned channel = output - Mixer::OUTPUT_INPUT0;
488                 previews[channel]->label->setText(name.c_str());
489         }
490 }
491
492 void MainWindow::update_channel_color(Mixer::Output output, const string &color)
493 {
494         if (output >= Mixer::OUTPUT_INPUT0) {
495                 unsigned channel = output - Mixer::OUTPUT_INPUT0;
496                 previews[channel]->frame->setStyleSheet(QString::fromStdString("background-color:" + color));
497         }
498 }
499
500 void MainWindow::transition_clicked(int transition_number)
501 {
502         global_mixer->transition_clicked(transition_number);
503 }
504
505 void MainWindow::channel_clicked(int channel_number)
506 {
507         if (current_wb_pick_display == channel_number) {
508                 // The picking was already done from eventFilter(), since we don't get
509                 // the mouse pointer here.
510         } else {
511                 global_mixer->channel_clicked(channel_number);
512         }
513 }
514
515 void MainWindow::wb_button_clicked(int channel_number)
516 {
517         current_wb_pick_display = channel_number;
518         QApplication::setOverrideCursor(Qt::CrossCursor);
519 }
520
521 bool MainWindow::eventFilter(QObject *watched, QEvent *event)
522 {
523         if (current_wb_pick_display != -1 &&
524             event->type() == QEvent::MouseButtonRelease &&
525             watched->isWidgetType()) {
526                 QApplication::restoreOverrideCursor();
527                 if (watched == previews[current_wb_pick_display]->display) {
528                         const QMouseEvent *mouse_event = (QMouseEvent *)event;
529                         set_white_balance(current_wb_pick_display, mouse_event->x(), mouse_event->y());
530                 } else {
531                         // The user clicked on something else, give up.
532                         // (The click goes through, which might not be ideal, but, yes.)
533                         current_wb_pick_display = -1;
534                 }
535         }
536         return false;
537 }
538
539 namespace {
540
541 double srgb_to_linear(double x)
542 {
543         if (x < 0.04045) {
544                 return x / 12.92;
545         } else {
546                 return pow((x + 0.055) / 1.055, 2.4);
547         }
548 }
549
550 }  // namespace
551
552 void MainWindow::set_white_balance(int channel_number, int x, int y)
553 {
554         // Set the white balance to neutral for the grab. It's probably going to
555         // flicker a bit, but hopefully this display is not live anyway.
556         global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, 0.5, 0.5, 0.5);
557         previews[channel_number]->display->updateGL();
558         QRgb reference_color = previews[channel_number]->display->grabFrameBuffer().pixel(x, y);
559
560         double r = srgb_to_linear(qRed(reference_color) / 255.0);
561         double g = srgb_to_linear(qGreen(reference_color) / 255.0);
562         double b = srgb_to_linear(qBlue(reference_color) / 255.0);
563         global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, r, g, b);
564         previews[channel_number]->display->updateGL();
565 }