diff options
Diffstat (limited to 'libs/surfaces/launch_control_xl')
-rw-r--r-- | libs/surfaces/launch_control_xl/controllers.cc | 50 | ||||
-rw-r--r-- | libs/surfaces/launch_control_xl/launch_control_xl.cc | 24 | ||||
-rw-r--r-- | libs/surfaces/launch_control_xl/launch_control_xl.h | 36 |
3 files changed, 55 insertions, 55 deletions
diff --git a/libs/surfaces/launch_control_xl/controllers.cc b/libs/surfaces/launch_control_xl/controllers.cc index 6621a15352..b8a72272a3 100644 --- a/libs/surfaces/launch_control_xl/controllers.cc +++ b/libs/surfaces/launch_control_xl/controllers.cc @@ -36,10 +36,10 @@ LaunchControlXL::build_maps () { /* Knobs */ - Knob* knob; + boost::shared_ptr<Knob> knob; #define MAKE_KNOB(i,cc, index) \ - knob = new Knob ((i), (cc), (index), (*this)); \ + knob.reset (new Knob ((i), (cc), (index), (*this))); \ cc_knob_map.insert (std::make_pair (knob->controller_number(), knob)); \ id_knob_map.insert (std::make_pair (knob->id(), knob)) @@ -51,10 +51,10 @@ LaunchControlXL::build_maps () /* Faders */ - Fader* fader; + boost::shared_ptr<Fader> fader; #define MAKE_FADER(i,cc) \ - fader = new Fader ((i), (cc)); \ + fader.reset (new Fader ((i), (cc))); \ cc_fader_map.insert (std::make_pair (fader->controller_number(), fader)); \ id_fader_map.insert (std::make_pair (fader->id(), fader)) @@ -64,24 +64,24 @@ LaunchControlXL::build_maps () /* Buttons */ - ControllerButton *controller_button; - NoteButton *note_button; + boost::shared_ptr<ControllerButton> controller_button; + boost::shared_ptr<NoteButton> note_button; #define MAKE_TRACK_BUTTON_PRESS(i,nn,index,color,p) \ - note_button = new TrackButton ((i), (nn), (index), (color), (p), (*this)); \ + note_button.reset (new TrackButton ((i), (nn), (index), (color), (p), (*this))); \ nn_note_button_map.insert (std::make_pair (note_button->note_number(), note_button)); \ id_note_button_map.insert (std::make_pair (note_button->id(), note_button)) #define MAKE_SELECT_BUTTON_PRESS(i,cc,index,p) \ - controller_button = new SelectButton ((i), (cc), (index), (p), (*this)); \ + controller_button.reset (new SelectButton ((i), (cc), (index), (p), (*this))); \ cc_controller_button_map.insert (std::make_pair (controller_button->controller_number(), controller_button)); \ id_controller_button_map.insert (std::make_pair (controller_button->id(), controller_button)) #define MAKE_TRACK_STATE_BUTTON_PRESS(i,nn,index,p) \ - note_button = new TrackStateButton ((i), (nn), (index), (p), (*this)); \ + note_button.reset (new TrackStateButton ((i), (nn), (index), (p), (*this))); \ nn_note_button_map.insert (std::make_pair (note_button->note_number(), note_button)); \ id_note_button_map.insert (std::make_pair (note_button->id(), note_button)) #define MAKE_TRACK_STATE_BUTTON_PRESS_RELEASE_LONG(i,nn,index, p,r,l) \ - note_button = new TrackStateButton ((i), (nn), (index), (p), (r), (l), (*this)); \ + note_button.reset (new TrackStateButton ((i), (nn), (index), (p), (r), (l), (*this))); \ nn_note_button_map.insert (std::make_pair (note_button->note_number(), note_button)); \ id_note_button_map.insert (std::make_pair (note_button->id(), note_button)) @@ -260,7 +260,7 @@ LaunchControlXL::fader_name_by_id (FaderID id) return "???"; } -LaunchControlXL::TrackButton* +boost::shared_ptr<LaunchControlXL::TrackButton> LaunchControlXL::track_button_by_range(uint8_t n, uint8_t first, uint8_t middle) { NNNoteButtonMap::iterator b; @@ -270,10 +270,10 @@ LaunchControlXL::track_button_by_range(uint8_t n, uint8_t first, uint8_t middle) b = nn_note_button_map.find (middle + n - 4); } - TrackButton* button = 0; + boost::shared_ptr<TrackButton> button = 0; if (b != nn_note_button_map.end()) { - button = static_cast<TrackButton*>(b->second); + button = boost::dynamic_pointer_cast<TrackButton> (b->second); } return button; @@ -283,7 +283,7 @@ LaunchControlXL::track_button_by_range(uint8_t n, uint8_t first, uint8_t middle) void LaunchControlXL::update_track_focus_led(uint8_t n) { - TrackButton* b = focus_button_by_column(n); + boost::shared_ptr<TrackButton> b = focus_button_by_column(n); if (!b) { return; @@ -350,8 +350,8 @@ LaunchControlXL::get_ac_by_state(uint8_t n) { return ac; } -LaunchControlXL::Knob** -LaunchControlXL::knobs_by_column(uint8_t col, Knob** knob_col) +boost::shared_ptr<LaunchControlXL::Knob>* +LaunchControlXL::knobs_by_column(uint8_t col, boost::shared_ptr<Knob>* knob_col) { for (uint8_t n = 0; n < 3; ++n) { knob_col[n] = id_knob_map.find(static_cast<KnobID>(col+n*8))->second; @@ -410,7 +410,7 @@ LaunchControlXL::update_knob_led(uint8_t n) } } - Knob* knobs_col[3]; + boost::shared_ptr<Knob> knobs_col[3]; knobs_by_column(n, knobs_col); for (uint8_t s = 0; s < 3; ++s) @@ -427,7 +427,7 @@ LaunchControlXL::update_knob_led(uint8_t n) void LaunchControlXL::update_track_control_led(uint8_t n) { - TrackButton* b = control_button_by_column(n); + boost::shared_ptr<TrackButton> b = control_button_by_column(n); if (!b) { return; @@ -504,7 +504,7 @@ LaunchControlXL::solo_iso_led_bank () return; } else { for (int n = 0; n < stripable_counter; ++n) { - TrackButton* b = focus_button_by_column(n); + boost::shared_ptr<TrackButton> b = focus_button_by_column(n); if (stripable[n] && stripable[n]->solo_isolate_control()) { if (stripable[n]->solo_isolate_control()->get_value()) { b->set_color(RedFull); @@ -539,7 +539,7 @@ LaunchControlXL::master_send_led_bank () int stripable_counter = LaunchControlXL::get_amount_of_tracks(); for (int n = 0; n < stripable_counter; ++n) { - TrackButton* b = control_button_by_column(n); + boost::shared_ptr<TrackButton> b = control_button_by_column(n); if (stripable[n] && stripable[n]->master_send_enable_controllable()) { if (stripable[n]->master_send_enable_controllable()->get_value()) { b->set_color(GreenFull); @@ -591,9 +591,9 @@ LaunchControlXL::button_track_mode(TrackMode state) update_track_control_led(n); } - TrackStateButton* mute = static_cast<TrackStateButton*>(id_note_button_map[Mute]); - TrackStateButton* solo = static_cast<TrackStateButton*>(id_note_button_map[Solo]); - TrackStateButton* record = static_cast<TrackStateButton*>(id_note_button_map[Record]); + boost::shared_ptr<TrackStateButton> mute = boost::dynamic_pointer_cast<TrackStateButton> (id_note_button_map[Mute]); + boost::shared_ptr<TrackStateButton> solo = boost::dynamic_pointer_cast<TrackStateButton> (id_note_button_map[Solo]); + boost::shared_ptr<TrackStateButton> record = boost::dynamic_pointer_cast<TrackStateButton> (id_note_button_map[Record]); write(mute->state_msg((state == TrackMute))); write(solo->state_msg((state == TrackSolo))); @@ -670,7 +670,7 @@ LaunchControlXL::button_record() } bool -LaunchControlXL::button_long_press_timeout (ButtonID id, Button* button) +LaunchControlXL::button_long_press_timeout (ButtonID id, boost::shared_ptr<Button> button) { if (buttons_down.find (id) != buttons_down.end()) { DEBUG_TRACE (DEBUG::LaunchControlXL, string_compose ("long press timeout for %1, invoking method\n", id)); @@ -690,7 +690,7 @@ LaunchControlXL::button_long_press_timeout (ButtonID id, Button* button) void -LaunchControlXL::start_press_timeout (Button* button, ButtonID id) +LaunchControlXL::start_press_timeout (boost::shared_ptr<Button> button, ButtonID id) { Glib::RefPtr<Glib::TimeoutSource> timeout = Glib::TimeoutSource::create (500); // milliseconds button->timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &LaunchControlXL::button_long_press_timeout), id, button)); diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.cc b/libs/surfaces/launch_control_xl/launch_control_xl.cc index 0c617205bf..35d56298d3 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.cc +++ b/libs/surfaces/launch_control_xl/launch_control_xl.cc @@ -408,13 +408,13 @@ LaunchControlXL::handle_midi_sysex (MIDI::Parser&, MIDI::byte* raw_bytes, size_t void -LaunchControlXL::handle_button_message(Button* button, MIDI::EventTwoBytes* ev) +LaunchControlXL::handle_button_message(boost::shared_ptr<Button> button, MIDI::EventTwoBytes* ev) { if (ev->value) { /* any press cancels any pending long press timeouts */ for (set<ButtonID>::iterator x = buttons_down.begin(); x != buttons_down.end(); ++x) { - ControllerButton* cb = id_controller_button_map[*x]; - NoteButton* nb = id_note_button_map[*x]; + boost::shared_ptr<ControllerButton> cb = id_controller_button_map[*x]; + boost::shared_ptr<NoteButton> nb = id_note_button_map[*x]; if (cb != 0) { cb->timeout_connection.disconnect(); } else if (nb != 0) { @@ -449,14 +449,14 @@ LaunchControlXL::handle_button_message(Button* button, MIDI::EventTwoBytes* ev) } bool -LaunchControlXL::check_pick_up(Controller* controller, boost::shared_ptr<AutomationControl> ac) +LaunchControlXL::check_pick_up(boost::shared_ptr<Controller> controller, boost::shared_ptr<AutomationControl> ac) { /* returns false until the controller value matches with the current setting of the stripable's ac */ return ( abs( controller->value() / 127.0 - ac->internal_to_interface(ac->get_value()) ) < 0.007875 ); } void -LaunchControlXL::handle_knob_message (Knob* knob) +LaunchControlXL::handle_knob_message (boost::shared_ptr<Knob> knob) { uint8_t chan = knob->id() % 8; // get the strip channel number if (!stripable[chan]) { @@ -499,7 +499,7 @@ LaunchControlXL::handle_knob_message (Knob* knob) } void -LaunchControlXL::handle_fader_message (Fader* fader) +LaunchControlXL::handle_fader_message (boost::shared_ptr<Fader> fader) { if (!stripable[fader->id()]) { @@ -527,15 +527,15 @@ LaunchControlXL::handle_midi_controller_message (MIDI::Parser& parser, MIDI::Eve CCKnobMap::iterator k = cc_knob_map.find (ev->controller_number); if (b != cc_controller_button_map.end()) { - Button* button = b->second; + boost::shared_ptr<Button> button = b->second; handle_button_message(button, ev); } else if (f != cc_fader_map.end()) { - Fader* fader = f->second; + boost::shared_ptr<Fader> fader = f->second; fader->set_value(ev->value); handle_fader_message(fader); } else if (k != cc_knob_map.end()) { - Knob* knob = k->second; + boost::shared_ptr<Knob> knob = k->second; knob->set_value(ev->value); handle_knob_message(knob); } @@ -555,7 +555,7 @@ LaunchControlXL::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventT NNNoteButtonMap::iterator b = nn_note_button_map.find (ev->controller_number); if (b != nn_note_button_map.end()) { - Button* button = b->second; + boost::shared_ptr<Button> button = b->second; handle_button_message(button, ev); } } @@ -851,8 +851,8 @@ LaunchControlXL::switch_template (uint8_t t) void LaunchControlXL::switch_bank (uint32_t base) { - SelectButton* sl = static_cast<SelectButton*>(id_controller_button_map[SelectLeft]); - SelectButton* sr = static_cast<SelectButton*>(id_controller_button_map[SelectRight]); + boost::shared_ptr<SelectButton> sl = boost::dynamic_pointer_cast<SelectButton>(id_controller_button_map[SelectLeft]); + boost::shared_ptr<SelectButton> sr = boost::dynamic_pointer_cast<SelectButton>(id_controller_button_map[SelectRight]); /* work backwards so we can tell if we should actually switch banks */ diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.h b/libs/surfaces/launch_control_xl/launch_control_xl.h index c6695f30b7..6fcc1893f3 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.h +++ b/libs/surfaces/launch_control_xl/launch_control_xl.h @@ -387,38 +387,38 @@ private: void relax() {} /* map of NoteButtons by NoteNumber */ - typedef std::map<int, NoteButton *> NNNoteButtonMap; + typedef std::map<int, boost::shared_ptr<NoteButton> > NNNoteButtonMap; NNNoteButtonMap nn_note_button_map; /* map of NoteButtons by ButtonID */ - typedef std::map<ButtonID, NoteButton *> IDNoteButtonMap; + typedef std::map<ButtonID, boost::shared_ptr<NoteButton> > IDNoteButtonMap; IDNoteButtonMap id_note_button_map; /* map of ControllerNoteButtons by CC */ - typedef std::map<int, ControllerButton *> CCControllerButtonMap; + typedef std::map<int, boost::shared_ptr<ControllerButton> > CCControllerButtonMap; CCControllerButtonMap cc_controller_button_map; /* map of ControllerButtons by ButtonID */ - typedef std::map<ButtonID, ControllerButton *> IDControllerButtonMap; + typedef std::map<ButtonID, boost::shared_ptr<ControllerButton> > IDControllerButtonMap; IDControllerButtonMap id_controller_button_map; /* map of Fader by CC */ - typedef std::map<int, Fader *> CCFaderMap; + typedef std::map<int, boost::shared_ptr<Fader> > CCFaderMap; CCFaderMap cc_fader_map; /* map of Fader by FaderID */ - typedef std::map<FaderID, Fader *> IDFaderMap; + typedef std::map<FaderID, boost::shared_ptr<Fader> > IDFaderMap; IDFaderMap id_fader_map; /* map of Knob by CC */ - typedef std::map<int, Knob *> CCKnobMap; + typedef std::map<int, boost::shared_ptr<Knob> > CCKnobMap; CCKnobMap cc_knob_map; /* map of Knob by KnobID */ - typedef std::map<KnobID, Knob *> IDKnobMap; + typedef std::map<KnobID, boost::shared_ptr<Knob> > IDKnobMap; IDKnobMap id_knob_map; std::set<ButtonID> buttons_down; std::set<ButtonID> consumed; - bool button_long_press_timeout(ButtonID id, Button *button); - void start_press_timeout(Button *, ButtonID); + bool button_long_press_timeout(ButtonID id, boost::shared_ptr<Button> button); + void start_press_timeout(boost::shared_ptr<Button> , ButtonID); void init_buttons(bool startup); @@ -437,11 +437,11 @@ private: boost::shared_ptr<ARDOUR::Port> _async_out; void connect_to_parser(); - void handle_button_message(Button* button, MIDI::EventTwoBytes *); - void handle_fader_message(Fader* fader); - void handle_knob_message(Knob* knob); + void handle_button_message(boost::shared_ptr<Button> button, MIDI::EventTwoBytes *); + void handle_fader_message(boost::shared_ptr<Fader> fader); + void handle_knob_message(boost::shared_ptr<Knob> knob); - bool check_pick_up(Controller* controller, boost::shared_ptr<ARDOUR::AutomationControl> ac); + bool check_pick_up(boost::shared_ptr<Controller> controller, boost::shared_ptr<ARDOUR::AutomationControl> ac); void handle_midi_controller_message(MIDI::Parser &, MIDI::EventTwoBytes *, MIDI::channel_t chan); void handle_midi_note_on_message(MIDI::Parser &, MIDI::EventTwoBytes *, MIDI::channel_t chan); @@ -460,14 +460,14 @@ private: /* Knob methods */ - Knob** knobs_by_column(uint8_t col, Knob** knob_col); + boost::shared_ptr<Knob>* knobs_by_column(uint8_t col, boost::shared_ptr<Knob>* knob_col); void update_knob_led(uint8_t n); /* Button methods */ - TrackButton* track_button_by_range(uint8_t n, uint8_t first, uint8_t middle); - TrackButton* focus_button_by_column(uint8_t col) { return track_button_by_range(col, 41, 57) ; } - TrackButton* control_button_by_column(uint8_t col) { return track_button_by_range(col, 73, 89) ; } + boost::shared_ptr<TrackButton> track_button_by_range(uint8_t n, uint8_t first, uint8_t middle); + boost::shared_ptr<TrackButton> focus_button_by_column(uint8_t col) { return track_button_by_range(col, 41, 57) ; } + boost::shared_ptr<TrackButton> control_button_by_column(uint8_t col) { return track_button_by_range(col, 73, 89) ; } void button_device(); |