]> git.sesse.net Git - nageru/blob - mainwindow.h
Update the queue length metric after trimming, not before.
[nageru] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <stdbool.h>
5 #include <sys/types.h>
6 #include <QMainWindow>
7 #include <QString>
8 #include <chrono>
9 #include <string>
10 #include <vector>
11
12 #include "analyzer.h"
13 #include "audio_mixer.h"
14 #include "midi_mapper.h"
15 #include "mixer.h"
16
17 class QEvent;
18 class QObject;
19 class QResizeEvent;
20 class Ui_AudioExpandedView;
21
22 namespace Ui {
23 class AudioExpandedView;
24 class AudioMiniView;
25 class Display;
26 class MainWindow;
27 }  // namespace Ui
28
29 class QLabel;
30 class QPushButton;
31
32 class MainWindow : public QMainWindow, public ControllerReceiver
33 {
34         Q_OBJECT
35
36 public:
37         MainWindow();
38         void resizeEvent(QResizeEvent *event) override;
39         void mixer_created(Mixer *mixer);
40
41         // Used to release FBOs on the global ResourcePool. Call after the
42         // mixer has been shut down but not destroyed yet.
43         void mixer_shutting_down();
44
45 public slots:
46         void cut_triggered();
47         void x264_bitrate_triggered();
48         void exit_triggered();
49         void manual_triggered();
50         void about_triggered();
51         void open_analyzer_triggered();
52         void simple_audio_mode_triggered();
53         void multichannel_audio_mode_triggered();
54         void input_mapping_triggered();
55         void midi_mapping_triggered();
56         void timecode_stream_triggered();
57         void timecode_stdout_triggered();
58         void transition_clicked(int transition_number);
59         void channel_clicked(int channel_number);
60         void wb_button_clicked(int channel_number);
61         void set_transition_names(std::vector<std::string> transition_names);
62         void update_channel_name(Mixer::Output output, const std::string &name);
63         void update_channel_color(Mixer::Output output, const std::string &color);
64         void gain_staging_knob_changed(unsigned bus_index, int value);
65         void final_makeup_gain_knob_changed(int value);
66         void cutoff_knob_changed(int value);
67         void eq_knob_changed(unsigned bus_index, EQBand band, int value);
68         void limiter_threshold_knob_changed(int value);
69         void compressor_threshold_knob_changed(unsigned bus_index, int value);
70         void mini_fader_changed(int bus, double db_volume);
71         void mute_button_toggled(int bus, bool checked);
72         void reset_meters_button_clicked();
73         void relayout();
74
75         // ControllerReceiver interface.
76         void set_locut(float value) override;
77         void set_limiter_threshold(float value) override;
78         void set_makeup_gain(float value) override;
79
80         void set_treble(unsigned bus_idx, float value) override;
81         void set_mid(unsigned bus_idx, float value) override;
82         void set_bass(unsigned bus_idx, float value) override;
83         void set_gain(unsigned bus_idx, float value) override;
84         void set_compressor_threshold(unsigned bus_idx, float value) override;
85         void set_fader(unsigned bus_idx, float value) override;
86
87         void toggle_mute(unsigned bus_idx) override;
88         void toggle_locut(unsigned bus_idx) override;
89         void toggle_auto_gain_staging(unsigned bus_idx) override;
90         void toggle_compressor(unsigned bus_idx) override;
91         void clear_peak(unsigned bus_idx) override;
92         void toggle_limiter() override;
93         void toggle_auto_makeup_gain() override;
94
95         void clear_all_highlights() override;
96
97         void highlight_locut(bool highlight) override;
98         void highlight_limiter_threshold(bool highlight) override;
99         void highlight_makeup_gain(bool highlight) override;
100
101         void highlight_treble(unsigned bus_idx, bool highlight) override;
102         void highlight_mid(unsigned bus_idx, bool highlight) override;
103         void highlight_bass(unsigned bus_idx, bool highlight) override;
104         void highlight_gain(unsigned bus_idx, bool highlight) override;
105         void highlight_compressor_threshold(unsigned bus_idx, bool highlight) override;
106         void highlight_fader(unsigned bus_idx, bool highlight) override;
107
108         void highlight_mute(unsigned bus_idx, bool highlight) override;
109         void highlight_toggle_locut(unsigned bus_idx, bool highlight) override;
110         void highlight_toggle_auto_gain_staging(unsigned bus_idx, bool highlight) override;
111         void highlight_toggle_compressor(unsigned bus_idx, bool highlight) override;
112         void highlight_clear_peak(unsigned bus_idx, bool highlight) override {}  // We don't mark this currently.
113         void highlight_toggle_limiter(bool highlight) override;
114         void highlight_toggle_auto_makeup_gain(bool highlight) override;
115
116         // Raw receivers are not used.
117         void controller_changed(unsigned controller) override {}
118         void note_on(unsigned note) override {}
119
120 private:
121         void reset_audio_mapping_ui();
122         void setup_audio_miniview();
123         void setup_audio_expanded_view();
124         bool eventFilter(QObject *watched, QEvent *event) override;
125         void closeEvent(QCloseEvent *event) override;
126         void set_white_balance(int channel_number, int x, int y);
127         void update_cutoff_labels(float cutoff_hz);
128         void update_eq_label(unsigned bus_index, EQBand band, float gain_db);
129
130         // Called from DiskSpaceEstimator.
131         void report_disk_space(off_t free_bytes, double estimated_seconds_left);
132
133         // Called from the mixer.
134         void audio_level_callback(float level_lufs, float peak_db, std::vector<AudioMixer::BusLevel> bus_levels, float global_level_lufs, float range_low_lufs, float range_high_lufs, float final_makeup_gain_db, float correlation);
135         std::chrono::steady_clock::time_point last_audio_level_callback;
136
137         void audio_state_changed();
138
139         template<class T>
140         void set_relative_value(T *control, float value);
141
142         template<class T>
143         void set_relative_value_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control, float value);
144
145         template<class T>
146         void click_button_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control);
147
148         template<class T>
149         void highlight_control(T *control, bool highlight);
150
151         template<class T>
152         void highlight_mute_control(T *control, bool highlight);
153
154         template<class T>
155         void highlight_control_if_exists(unsigned bus_idx, T *(Ui_AudioExpandedView::*control), bool highlight, bool is_mute_button = false);
156
157         Ui::MainWindow *ui;
158         QLabel *disk_free_label;
159         QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
160         std::vector<Ui::Display *> previews;
161         std::vector<Ui::AudioMiniView *> audio_miniviews;
162         std::vector<Ui::AudioExpandedView *> audio_expanded_views;
163         int current_wb_pick_display = -1;
164         MIDIMapper midi_mapper;
165         std::unique_ptr<Analyzer> analyzer;
166 };
167
168 extern MainWindow *global_mainwindow;
169
170 #endif