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