]> git.sesse.net Git - nageru/blob - mainwindow.h
Add support for controlling the audio using a MIDI controller.
[nageru] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <QMainWindow>
5 #include <chrono>
6 #include <string>
7 #include <vector>
8 #include <sys/time.h>
9
10 #include "midi_mapper.h"
11 #include "mixer.h"
12
13 class GLWidget;
14 class Ui_AudioExpandedView;
15 class QResizeEvent;
16
17 namespace Ui {
18 class AudioExpandedView;
19 class AudioMiniView;
20 class Display;
21 class MainWindow;
22 }  // namespace Ui
23
24 class QDial;
25 class QLabel;
26 class QPushButton;
27
28 class MainWindow : public QMainWindow, public ControllerReceiver
29 {
30         Q_OBJECT
31
32 public:
33         MainWindow();
34         void resizeEvent(QResizeEvent *event) override;
35         void mixer_created(Mixer *mixer);
36
37         // Used to release FBOs on the global ResourcePool. Call after the
38         // mixer has been shut down but not destroyed yet.
39         void mixer_shutting_down();
40
41 public slots:
42         void cut_triggered();
43         void x264_bitrate_triggered();
44         void exit_triggered();
45         void about_triggered();
46         void simple_audio_mode_triggered();
47         void multichannel_audio_mode_triggered();
48         void input_mapping_triggered();
49         void transition_clicked(int transition_number);
50         void channel_clicked(int channel_number);
51         void wb_button_clicked(int channel_number);
52         void set_transition_names(std::vector<std::string> transition_names);
53         void update_channel_name(Mixer::Output output, const std::string &name);
54         void update_channel_color(Mixer::Output output, const std::string &color);
55         void gain_staging_knob_changed(unsigned bus_index, int value);
56         void final_makeup_gain_knob_changed(int value);
57         void cutoff_knob_changed(int value);
58         void eq_knob_changed(unsigned bus_index, EQBand band, int value);
59         void limiter_threshold_knob_changed(int value);
60         void compressor_threshold_knob_changed(unsigned bus_index, int value);
61         void mini_fader_changed(int bus, double db_volume);
62         void reset_meters_button_clicked();
63         void relayout();
64
65         // ControllerReceiver interface.
66         void set_locut(float value) override;
67         void set_limiter_threshold(float value) override;
68         void set_makeup_gain(float value) override;
69
70         void set_treble(unsigned bus_idx, float value) override;
71         void set_mid(unsigned bus_idx, float value) override;
72         void set_bass(unsigned bus_idx, float value) override;
73         void set_gain(unsigned bus_idx, float value) override;
74         void set_compressor_threshold(unsigned bus_idx, float value) override;
75         void set_fader(unsigned bus_idx, float value) override;
76
77         void toggle_locut(unsigned bus_idx) override;
78         void toggle_auto_gain_staging(unsigned bus_idx) override;
79         void toggle_compressor(unsigned bus_idx) override;
80         void clear_peak(unsigned bus_idx) override;
81
82 private:
83         void reset_audio_mapping_ui();
84         void setup_audio_miniview();
85         void setup_audio_expanded_view();
86         bool eventFilter(QObject *watched, QEvent *event) override;
87         void set_white_balance(int channel_number, int x, int y);
88         void update_cutoff_labels(float cutoff_hz);
89         void update_eq_label(unsigned bus_index, EQBand band, float gain_db);
90
91         // Called from DiskSpaceEstimator.
92         void report_disk_space(off_t free_bytes, double estimated_seconds_left);
93
94         // Called from the mixer.
95         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);
96         std::chrono::steady_clock::time_point last_audio_level_callback;
97
98         void audio_state_changed();
99
100         template<class T>
101         void set_relative_value(T *control, float value);
102
103         template<class T>
104         void set_relative_value_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control, float value);
105
106         template<class T>
107         void click_button_if_exists(unsigned bus_idx, T *Ui_AudioExpandedView::*control);
108
109         Ui::MainWindow *ui;
110         QLabel *disk_free_label;
111         QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
112         std::vector<Ui::Display *> previews;
113         std::vector<Ui::AudioMiniView *> audio_miniviews;
114         std::vector<Ui::AudioExpandedView *> audio_expanded_views;
115         int current_wb_pick_display = -1;
116         MIDIMapper midi_mapper;
117 };
118
119 extern MainWindow *global_mainwindow;
120
121 #endif