]> git.sesse.net Git - nageru/blob - nageru/mainwindow.h
Add metrics for how many frames we are decoding, but did not have the time to display.
[nageru] / 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 QDial;
18 class QEvent;
19 class QObject;
20 class QResizeEvent;
21 class Ui_AudioExpandedView;
22
23 namespace Ui {
24 class AudioExpandedView;
25 class AudioMiniView;
26 class Display;
27 class MainWindow;
28 }  // namespace Ui
29
30 class QLabel;
31 class QPushButton;
32
33 class MainWindow : public QMainWindow, public ControllerReceiver
34 {
35         Q_OBJECT
36
37 public:
38         MainWindow();
39         void resizeEvent(QResizeEvent *event) override;
40         void mixer_created(Mixer *mixer);
41
42         // Used to release FBOs on the global ResourcePool. Call after the
43         // mixer has been shut down but not destroyed yet.
44         void mixer_shutting_down();
45
46 public slots:
47         void cut_triggered();
48         void x264_bitrate_triggered();
49         void exit_triggered();
50         void manual_triggered();
51         void about_triggered();
52         void open_analyzer_triggered();
53         void simple_audio_mode_triggered();
54         void multichannel_audio_mode_triggered();
55         void input_mapping_triggered();
56         void midi_mapping_triggered();
57         void timecode_stream_triggered();
58         void timecode_stdout_triggered();
59         void transition_clicked(int transition_number);
60         void channel_clicked(int channel_number);
61         void quick_cut_activated(int channel_number);
62         void wb_button_clicked(int channel_number);
63         void audio_view_changed(int audio_view);
64         void set_transition_names(std::vector<std::string> transition_names);
65         void update_channel_name(Mixer::Output output, const std::string &name);
66         void update_channel_color(Mixer::Output output, const std::string &color);
67         void gain_staging_knob_changed(unsigned bus_index, int value);
68         void final_makeup_gain_knob_changed(int value);
69         void cutoff_knob_changed(int value);
70         void stereo_width_knob_changed(unsigned bus_index, int value);
71         void eq_knob_changed(unsigned bus_index, EQBand band, int value);
72         void limiter_threshold_knob_changed(int value);
73         void compressor_threshold_knob_changed(unsigned bus_index, int value);
74         void mini_fader_changed(int bus, double db_volume);
75         void mute_button_toggled(int bus, bool checked);
76         void reset_meters_button_clicked();
77         void relayout();
78
79         // ControllerReceiver interface.
80         void set_locut(float value) override;
81         void set_limiter_threshold(float value) override;
82         void set_makeup_gain(float value) override;
83
84         void set_stereo_width(unsigned bus_idx, float value) override;
85         void set_treble(unsigned bus_idx, float value) override;
86         void set_mid(unsigned bus_idx, float value) override;
87         void set_bass(unsigned bus_idx, float value) override;
88         void set_eq_absolute(unsigned bus_idx, EQBand eq_band, float value_db);
89         void set_gain(unsigned bus_idx, float value) override;
90         void set_compressor_threshold(unsigned bus_idx, float value) override;
91         void set_fader(unsigned bus_idx, float value) override;
92         void set_fader_absolute(unsigned bus_idx, float value_db);  // Used by the theme only.
93
94         void toggle_mute(unsigned bus_idx) override;
95         void toggle_locut(unsigned bus_idx) override;
96         void toggle_auto_gain_staging(unsigned bus_idx) override;
97         void toggle_compressor(unsigned bus_idx) override;
98         void clear_peak(unsigned bus_idx) override;
99         void toggle_limiter() override;
100         void toggle_auto_makeup_gain() override;
101
102         void switch_video_channel(int channel_number) override;
103         void apply_transition(int transition_number) override;
104         void prev_audio_view() override;
105         void next_audio_view() override;
106         void begin_new_segment() override;
107         void exit() override;
108
109         void clear_all_highlights() override;
110
111         void highlight_locut(bool highlight) override;
112         void highlight_limiter_threshold(bool highlight) override;
113         void highlight_makeup_gain(bool highlight) override;
114
115         void highlight_stereo_width(unsigned bus_idx, bool highlight) override;
116         void highlight_treble(unsigned bus_idx, bool highlight) override;
117         void highlight_mid(unsigned bus_idx, bool highlight) override;
118         void highlight_bass(unsigned bus_idx, bool highlight) override;
119         void highlight_gain(unsigned bus_idx, bool highlight) override;
120         void highlight_compressor_threshold(unsigned bus_idx, bool highlight) override;
121         void highlight_fader(unsigned bus_idx, bool highlight) override;
122
123         void highlight_mute(unsigned bus_idx, bool highlight) override;
124         void highlight_toggle_locut(unsigned bus_idx, bool highlight) override;
125         void highlight_toggle_auto_gain_staging(unsigned bus_idx, bool highlight) override;
126         void highlight_toggle_compressor(unsigned bus_idx, bool highlight) override;
127         void highlight_clear_peak(unsigned bus_idx, bool highlight) override {}  // We don't mark this currently.
128         void highlight_toggle_limiter(bool highlight) override;
129         void highlight_toggle_auto_makeup_gain(bool highlight) override;
130
131         // Raw receivers are not used.
132         void controller_changed(unsigned controller) override {}
133         void note_on(unsigned note) override {}
134
135 private:
136         void reset_audio_mapping_ui();
137         void setup_audio_miniview();
138         void setup_audio_expanded_view();
139         bool eventFilter(QObject *watched, QEvent *event) override;
140         void closeEvent(QCloseEvent *event) override;
141         void update_cutoff_labels(float cutoff_hz);
142         void update_stereo_knob_and_label(unsigned bus_index, int stereo_width_percent);
143         void update_stereo_label(unsigned bus_index, int stereo_width_percent);
144         void update_eq_label(unsigned bus_index, EQBand band, float gain_db);
145         void setup_theme_menu();
146         void fill_menu_from_theme_menu(const std::vector<std::unique_ptr<Theme::MenuEntry>> &entries, QMenu *menu);
147         void prev_page();
148         void next_page();
149
150         // Called from DiskSpaceEstimator.
151         void report_disk_space(off_t free_bytes, double estimated_seconds_left, double file_length_seconds);
152
153         // Called from the mixer.
154         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);
155         std::chrono::steady_clock::time_point last_audio_level_callback;
156
157         void audio_state_changed();
158
159         template<class T>
160         void set_relative_value(T *control, float value);
161
162         template<class T>
163         void set_relative_value_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control, float value);
164
165         void set_db_value_if_exists(unsigned bus_idx, QDial *Ui_AudioExpandedView::*control, float value_db);
166
167         template<class T>
168         void click_button_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control);
169
170         template<class T>
171         void highlight_control(T *control, bool highlight);
172
173         template<class T>
174         void highlight_mute_control(T *control, bool highlight);
175
176         template<class T>
177         void highlight_control_if_exists(unsigned bus_idx, T *(Ui_AudioExpandedView::*control), bool highlight, bool is_mute_button = false);
178
179         Ui::MainWindow *ui;
180         QLabel *disk_free_label;
181         QMenu *theme_menu = nullptr;
182         QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
183         std::vector<Ui::Display *> previews;
184         std::vector<Ui::AudioMiniView *> audio_miniviews;
185         std::vector<Ui::AudioExpandedView *> audio_expanded_views;
186         int current_wb_pick_display = -1;
187         int current_audio_view = -1;
188         MIDIMapper midi_mapper;
189         std::unique_ptr<Analyzer> analyzer;
190 };
191
192 extern MainWindow *global_mainwindow;
193
194 #endif