X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=midi_mapper.h;h=0a6694bd6a6ca0bcf85b78033acb53a68ffc27b2;hb=2f279ea7b988bdf204f6ba397b955dac28000133;hp=2b59b9ff53428cb1a02656049313014ee04548b4;hpb=6379b0adf2cee84b46d5a0d8e2ee5e6a7d1615cf;p=nageru diff --git a/midi_mapper.h b/midi_mapper.h index 2b59b9f..0a6694b 100644 --- a/midi_mapper.h +++ b/midi_mapper.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,30 @@ public: virtual void toggle_auto_gain_staging(unsigned bus_idx) = 0; virtual void toggle_compressor(unsigned bus_idx) = 0; virtual void clear_peak(unsigned bus_idx) = 0; + + // Signals to highlight controls to mark them to the user + // as MIDI-controllable (or not). + virtual void clear_all_highlights() = 0; + + virtual void highlight_locut(bool highlight) = 0; + virtual void highlight_limiter_threshold(bool highlight) = 0; + virtual void highlight_makeup_gain(bool highlight) = 0; + + virtual void highlight_treble(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_mid(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_bass(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_gain(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_compressor_threshold(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_fader(unsigned bus_idx, bool highlight) = 0; + + virtual void highlight_toggle_locut(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_toggle_auto_gain_staging(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_toggle_compressor(unsigned bus_idx, bool highlight) = 0; + virtual void highlight_clear_peak(unsigned bus_idx, bool highlight) = 0; + + // Raw events; used for the editor dialog only. + virtual void controller_changed(unsigned controller) = 0; + virtual void note_on(unsigned note) = 0; }; class MIDIMapper { @@ -46,7 +71,12 @@ public: virtual ~MIDIMapper(); void set_midi_mapping(const MIDIMappingProto &new_mapping); void start_thread(); - const MIDIMappingProto &get_current_mapping() const { return *mapping_proto; } + const MIDIMappingProto &get_current_mapping() const; + + // Overwrites and returns the previous value. + ControllerReceiver *set_receiver(ControllerReceiver *new_receiver); + + void refresh_highlights(); private: void thread_func(); @@ -54,19 +84,24 @@ private: void subscribe_to_port(snd_seq_t *seq, const snd_seq_addr_t &addr); void match_controller(int controller, int field_number, int bank_field_number, float value, std::function func); void match_button(int note, int field_number, int bank_field_number, std::function func); + bool has_active_controller(unsigned bus_idx, int field_number, int bank_field_number); // Also works for buttons. bool bank_mismatch(int bank_field_number); - ControllerReceiver *receiver; + void update_highlights(); + std::atomic should_quit{false}; int should_quit_fd; - std::unique_ptr mapping_proto; - int num_controller_banks; - int current_controller_bank = 0; + mutable std::mutex mapping_mu; + ControllerReceiver *receiver; // Under . + std::unique_ptr mapping_proto; // Under . + int num_controller_banks; // Under . + std::atomic current_controller_bank{0}; std::thread midi_thread; }; bool load_midi_mapping_from_file(const std::string &filename, MIDIMappingProto *new_mapping); +bool save_midi_mapping_to_file(const MIDIMappingProto &mapping_proto, const std::string &filename); #endif // !defined(_MIDI_MAPPER_H)