1 #ifndef _MIDI_MAPPING_DIALOG_H
2 #define _MIDI_MAPPING_DIALOG_H
9 #include "audio_mixer.h"
10 #include "midi_mapper.h"
14 class MIDIMappingDialog;
18 class MIDIMappingProto;
21 class QTreeWidgetItem;
23 class MIDIMappingDialog : public QDialog, public ControllerReceiver
28 MIDIMappingDialog(MIDIMapper *mapper);
31 // For use in midi_mapping_dialog.cpp only.
34 int field_number; // In MIDIMappingBusProto.
35 int bank_field_number; // In MIDIMappingProto.
38 // ControllerReceiver interface. We only implement the raw events.
39 // All values are [0.0, 1.0].
40 void set_locut(float value) override {}
41 void set_limiter_threshold(float value) override {}
42 void set_makeup_gain(float value) override {}
44 void set_treble(unsigned bus_idx, float value) override {}
45 void set_mid(unsigned bus_idx, float value) override {}
46 void set_bass(unsigned bus_idx, float value) override {}
47 void set_gain(unsigned bus_idx, float value) override {}
48 void set_compressor_threshold(unsigned bus_idx, float value) override {}
49 void set_fader(unsigned bus_idx, float value) override {}
51 void toggle_locut(unsigned bus_idx) override {}
52 void toggle_auto_gain_staging(unsigned bus_idx) override {}
53 void toggle_compressor(unsigned bus_idx) override {}
54 void clear_peak(unsigned bus_idx) override {}
56 // Raw events; used for the editor dialog only.
57 void controller_changed(unsigned controller) override;
58 void note_on(unsigned note) override;
62 void cancel_clicked();
67 static constexpr unsigned num_buses = 8;
69 void add_bank_selector(QTreeWidgetItem *item, const MIDIMappingProto &mapping_proto, int bank_field_number);
71 enum class ControlType { CONTROLLER, BUTTON };
72 void add_controls(const std::string &heading, ControlType control_type,
73 const MIDIMappingProto &mapping_proto, const std::vector<Control> &controls);
74 void fill_controls_from_mapping(const MIDIMappingProto &mapping_proto);
76 std::unique_ptr<MIDIMappingProto> construct_mapping_proto_from_ui();
78 Ui::MIDIMappingDialog *ui;
80 ControllerReceiver *old_receiver;
82 // All controllers actually laid out on the grid (we need to store them
83 // so that we can move values back and forth between the controls and
84 // the protobuf on save/load).
85 struct InstantiatedSpinner {
88 int field_number; // In MIDIMappingBusProto.
90 struct InstantiatedComboBox {
92 int field_number; // In MIDIMappingProto.
94 std::vector<InstantiatedSpinner> controller_spinners;
95 std::vector<InstantiatedSpinner> button_spinners;
96 std::vector<InstantiatedComboBox> bank_combo_boxes;
99 #endif // !defined(_MIDI_MAPPING_DIALOG_H)