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);
}
}
/* catch up on state */
- notify_transport_state_changed ();
- notify_record_state_changed ();
+ map_transport_state ();
+ map_recenable_state ();
}
int
}
void
-FaderPort::notify_record_state_changed ()
+FaderPort::map_recenable_state ()
{
switch (session->record_status()) {
case Session::Disabled:
}
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);
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);
}
}
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;
buf[1] = out;
buf[2] = onoff ? 1 : 0;
port->write (buf, 3, 0);
- led_on = (onoff ? true : false);
}
int
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
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);
+ }
}
}
, name (str)
, id (i)
, out (o)
- , led_on (false)
, flash (false)
{}
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; }
std::string name;
ButtonID id;
int out;
- bool led_on;
bool flash;
struct ToDo {
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;