diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-26 22:59:54 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-26 23:00:12 -0600 |
commit | 38c61b6dab3b1ae926ec4b791c1fa4dd04463664 (patch) | |
tree | 9b6949029d6531df135929eef033453266e7f383 /gtk2_ardour/transport_control.cc | |
parent | 1983f56592dfea5f74983c3b7207f8c6e0ab7836 (diff) |
fix design and implementation of (GUI) transport controllables to make them usable with MIDI CC control
The old code meant that their current value was always zero, and that they would do nothing unless
the new value exceeded 0.5
Diffstat (limited to 'gtk2_ardour/transport_control.cc')
-rw-r--r-- | gtk2_ardour/transport_control.cc | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/gtk2_ardour/transport_control.cc b/gtk2_ardour/transport_control.cc index 5d642e6132..a7be5903d7 100644 --- a/gtk2_ardour/transport_control.cc +++ b/gtk2_ardour/transport_control.cc @@ -16,12 +16,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "pbd/i18n.h" + +#include "ardour/location.h" +#include "ardour/session.h" + #include "actions.h" #include "ardour_ui.h" #include "transport_control.h" -#include "pbd/i18n.h" - using namespace Gtk; TransportControlProvider::TransportControlProvider () @@ -43,7 +46,7 @@ TransportControlProvider::TransportControllable::TransportControllable (std::str void TransportControlProvider::TransportControllable::set_value (double val, PBD::Controllable::GroupControlDisposition /*group_override*/) { - if (val < 0.5) { + if (val == 0.0) { /* do nothing: these are radio-style actions */ return; } @@ -86,3 +89,40 @@ TransportControlProvider::TransportControllable::set_value (double val, PBD::Con act->activate (); } } + +double +TransportControlProvider::TransportControllable::get_value () const +{ + if (!_session) { + return 0.0; + } + + ARDOUR::Location* rloc; + + switch (type) { + case Roll: + return (_session->transport_rolling() ? 1.0 : 0.0); + case Stop: + return (!_session->transport_rolling() ? 1.0 : 0.0); + case GotoStart: + if ((rloc = _session->locations()->session_range_location()) != 0) { + return (_session->transport_sample() == rloc->start() ? 1.0 : 0.0); + } + return 0.0; + case GotoEnd: + if ((rloc = _session->locations()->session_range_location()) != 0) { + return (_session->transport_sample() == rloc->end() ? 1.0 : 0.0); + } + return 0.0; + case AutoLoop: + return ((_session->get_play_loop() && _session->transport_rolling())? 1.0 : 0.0); + case PlaySelection: + return ((_session->transport_rolling() && _session->get_play_range()) ? 1.0 : 0.0); + case RecordEnable: + return (_session->actively_recording() ? 1.0 : 0.0); + default: + break; + } + + return 0.0; +} |