diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-08 11:07:37 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-08 11:09:50 -0500 |
commit | 6c995762508a6d7a507e726a742f456a6fa5b2a7 (patch) | |
tree | 283f3d94f8e187b49cea0b9cea3d972054b73db5 /libs/surfaces | |
parent | fe0802169ccca2d7c5458841928580db91548154 (diff) |
faderport: stop trying to cache LED state (fixes various bugs); blink mute for muted-by-others; blink transport for speed != 1.0 && != 0
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/faderport/faderport.cc | 68 | ||||
-rw-r--r-- | libs/surfaces/faderport/faderport.h | 8 |
2 files changed, 51 insertions, 25 deletions
diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 97155480e7..14e26dd45e 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -281,7 +281,7 @@ void FaderPort::all_lights_out () { for (ButtonMap::iterator b = buttons.begin(); b != buttons.end(); ++b) { - b->second.set_led_state (_output_port, false, true); + b->second.set_led_state (_output_port, false); } } @@ -535,8 +535,8 @@ FaderPort::sysex_handler (MIDI::Parser &p, MIDI::byte *buf, size_t sz) /* catch up on state */ - notify_transport_state_changed (); - notify_record_state_changed (); + map_transport_state (); + map_recenable_state (); } int @@ -618,7 +618,7 @@ FaderPort::close () } void -FaderPort::notify_record_state_changed () +FaderPort::map_recenable_state () { switch (session->record_status()) { case Session::Disabled: @@ -634,10 +634,21 @@ FaderPort::notify_record_state_changed () } void -FaderPort::notify_transport_state_changed () +FaderPort::map_transport_state () { get_button (Loop).set_led_state (_output_port, session->get_play_loop()); - get_button (Play).set_led_state (_output_port, session->transport_speed() == 1.0); + + float ts = session->transport_speed(); + + if (ts == 0) { + stop_blinking (Play); + } else if (fabs (ts) == 1.0) { + stop_blinking (Play); + get_button (Play).set_led_state (_output_port, true); + } else { + start_blinking (Play); + } + get_button (Stop).set_led_state (_output_port, session->transport_stopped ()); get_button (Rewind).set_led_state (_output_port, session->transport_speed() < 0.0); get_button (Ffwd).set_led_state (_output_port, session->transport_speed() > 1.0); @@ -663,8 +674,8 @@ FaderPort::parameter_changed (string what) void FaderPort::connect_session_signals() { - session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::notify_record_state_changed, this), this); - session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::notify_transport_state_changed, this), this); + session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_recenable_state, this), this); + session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::map_transport_state, this), this); /* not session, but treat it similarly */ session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort::parameter_changed, this, _1), this); } @@ -933,13 +944,8 @@ FaderPort::Button::set_action (boost::function<void()> f, bool when_pressed, Fad } void -FaderPort::Button::set_led_state (boost::shared_ptr<MIDI::Port> port, int onoff, bool force) +FaderPort::Button::set_led_state (boost::shared_ptr<MIDI::Port> port, bool onoff) { - if (!force && (led_on == (bool) onoff)) { - /* nothing to do */ - return; - } - if (out < 0) { /* fader button ID - no LED */ return; @@ -950,7 +956,6 @@ FaderPort::Button::set_led_state (boost::shared_ptr<MIDI::Port> port, int onoff, buf[1] = out; buf[2] = onoff ? 1 : 0; port->write (buf, 3, 0); - led_on = (onoff ? true : false); } int @@ -1151,19 +1156,38 @@ FaderPort::map_cut () void FaderPort::map_mute (void*) { - get_button (Mute).set_led_state (_output_port, _current_route->muted()); + if (_current_route) { + if (_current_route->muted()) { + stop_blinking (Mute); + get_button (Mute).set_led_state (_output_port, true); + } else if (_current_route->muted_by_others()) { + start_blinking (Mute); + } else { + stop_blinking (Mute); + } + } else { + stop_blinking (Mute); + } } void FaderPort::map_solo (bool, void*, bool) { - get_button (Solo).set_led_state (_output_port, _current_route->soloed() || _current_route->listening_via_monitor()); + if (_current_route) { + get_button (Solo).set_led_state (_output_port, _current_route->soloed() || _current_route->listening_via_monitor()); + } else { + get_button (Solo).set_led_state (_output_port, false); + } } void FaderPort::map_listen (void*, bool) { - get_button (Solo).set_led_state (_output_port, _current_route->listening_via_monitor()); + if (_current_route) { + get_button (Solo).set_led_state (_output_port, _current_route->listening_via_monitor()); + } else { + get_button (Solo).set_led_state (_output_port, false); + } } void @@ -1236,12 +1260,16 @@ FaderPort::map_route_state () get_button (Rec).set_led_state (_output_port, false); } else { /* arguments to these map_*() methods are all ignored */ - map_mute (0); map_solo (false, 0, false); map_recenable (); map_gain (); - map_cut (); map_auto (); + + if (_current_route == session->monitor_out()) { + map_cut (); + } else { + map_mute (0); + } } } diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 326bde6db1..9227f1f39f 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -222,7 +222,6 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq , name (str) , id (i) , out (o) - , led_on (false) , flash (false) {} @@ -230,7 +229,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq void set_action (boost::function<void()> function, bool on_press, FaderPort::ButtonState = ButtonState (0)); std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0)); - void set_led_state (boost::shared_ptr<MIDI::Port>, int onoff, bool force = false); + void set_led_state (boost::shared_ptr<MIDI::Port>, bool onoff); void invoke (ButtonState bs, bool press); bool uses_flash () const { return flash; } void set_flash (bool yn) { flash = yn; } @@ -245,7 +244,6 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq std::string name; ButtonID id; int out; - bool led_on; bool flash; struct ToDo { @@ -280,8 +278,8 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq PBD::ScopedConnectionList session_connections; void connect_session_signals (); - void notify_record_state_changed (); - void notify_transport_state_changed (); + void map_recenable_state (); + void map_transport_state (); sigc::connection blink_connection; typedef std::list<ButtonID> Blinkers; |