summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-04-13 03:46:38 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-04-13 03:46:38 +0000
commitf511b7cc6b504926b8885aeb8fc7bafd1212887a (patch)
tree1136f3ded53ab8ef5be8e0d44c08e5887750434c /libs
parent25d8f0ce6ae2db3bb92c7fea6caf6dc83dba84d0 (diff)
show gain level as its adjusted from ardour GUI (not reverted back); basic support for select/solo/mute/recenabel range ops, but not functioning yet
git-svn-id: svn://localhost/ardour2/branches/3.0@11958 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc178
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.h24
-rw-r--r--libs/surfaces/mackie/strip.cc53
-rw-r--r--libs/surfaces/mackie/strip.h2
4 files changed, 243 insertions, 14 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 2486cb3023..ac5dc59044 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -1194,3 +1194,181 @@ MackieControlProtocol::transport_frame() const
{
return session->transport_frame();
}
+
+void
+MackieControlProtocol::add_down_select_button (int surface, int strip)
+{
+ _down_select_buttons.push_back ((surface<<8)|(strip&0xf));
+}
+
+void
+MackieControlProtocol::remove_down_select_button (int surface, int strip)
+{
+ list<uint32_t>::iterator x = find (_down_select_buttons.begin(), _down_select_buttons.end(), (surface<<8)|(strip&0xf));
+ if (x != _down_select_buttons.end()) {
+ _down_select_buttons.erase (x);
+ }
+}
+
+bool
+MackieControlProtocol::select_range ()
+{
+ vector<boost::shared_ptr<Route> > routes;
+ pull_route_range (_down_select_buttons, routes);
+
+ if (routes.empty()) {
+ return false;
+ }
+
+ /* do something */
+
+ return true;
+}
+
+void
+MackieControlProtocol::add_down_solo_button (int surface, int strip)
+{
+ _down_solo_buttons.push_back ((surface<<8)|(strip&0xf));
+}
+
+void
+MackieControlProtocol::remove_down_solo_button (int surface, int strip)
+{
+ list<uint32_t>::iterator x = find (_down_solo_buttons.begin(), _down_solo_buttons.end(), (surface<<8)|(strip&0xf));
+ if (x != _down_solo_buttons.end()) {
+ _down_solo_buttons.erase (x);
+ }
+}
+
+bool
+MackieControlProtocol::solo_range ()
+{
+ vector<boost::shared_ptr<Route> > routes;
+ pull_route_range (_down_solo_buttons, routes);
+
+ if (routes.empty()) {
+ return false;
+ }
+
+ /* do something */
+
+ return true;
+}
+
+void
+MackieControlProtocol::add_down_mute_button (int surface, int strip)
+{
+ _down_mute_buttons.push_back ((surface<<8)|(strip&0xf));
+}
+
+void
+MackieControlProtocol::remove_down_mute_button (int surface, int strip)
+{
+ list<uint32_t>::iterator x = find (_down_mute_buttons.begin(), _down_mute_buttons.end(), (surface<<8)|(strip&0xf));
+ if (x != _down_mute_buttons.end()) {
+ _down_mute_buttons.erase (x);
+ }
+}
+
+bool
+MackieControlProtocol::mute_range ()
+{
+ vector<boost::shared_ptr<Route> > routes;
+ pull_route_range (_down_mute_buttons, routes);
+
+ if (routes.empty()) {
+ return false;
+ }
+
+ /* do something */
+
+ return true;
+}
+
+void
+MackieControlProtocol::add_down_recenable_button (int surface, int strip)
+{
+ _down_recenable_buttons.push_back ((surface<<8)|(strip&0xf));
+}
+
+void
+MackieControlProtocol::remove_down_recenable_button (int surface, int strip)
+{
+ list<uint32_t>::iterator x = find (_down_recenable_buttons.begin(), _down_recenable_buttons.end(), (surface<<8)|(strip&0xf));
+ if (x != _down_recenable_buttons.end()) {
+ _down_recenable_buttons.erase (x);
+ }
+}
+
+bool
+MackieControlProtocol::recenable_range ()
+{
+ vector<boost::shared_ptr<Route> > routes;
+ pull_route_range (_down_recenable_buttons, routes);
+
+ if (routes.empty()) {
+ return false;
+ }
+
+ /* do something */
+
+ return true;
+}
+
+
+struct ButtonRangeSorter {
+ bool operator() (const uint32_t& a, const uint32_t& b) {
+ return (a>>8) < (b>>8) // a.surface < b.surface
+ ||
+ ((a>>8) == (b>>8) && (a&0xf) < (b&0xf)); // a.surface == b.surface && a.strip < b.strip
+ }
+};
+
+void
+MackieControlProtocol::pull_route_range (list<uint32_t>& down, vector<boost::shared_ptr<Route> >& selected)
+{
+ ButtonRangeSorter cmp;
+
+ if (down.empty()) {
+ return;
+ }
+
+ down.sort (cmp);
+
+ uint32_t first = down.front();
+ uint32_t last = down.back ();
+
+ uint32_t first_surface = first>>8;
+ uint32_t first_strip = first&0x8;
+
+ uint32_t last_surface = last>>8;
+ uint32_t last_strip = last&0x8;
+
+ for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+
+ if ((*s)->number() >= first_surface && (*s)->number() <= last_surface) {
+
+ uint32_t fs;
+ uint32_t ls;
+
+ if ((*s)->number() == first_surface) {
+ fs = first_strip;
+ } else {
+ fs = 0;
+ }
+
+ if ((*s)->number() == last_surface) {
+ ls = last_strip;
+ } else {
+ ls = (*s)->n_strips ();
+ }
+
+ for (uint32_t n = fs; n < ls; ++n) {
+ boost::shared_ptr<Route> r = (*s)->nth_strip (n)->route();
+ if (r) {
+ selected.push_back (r);
+ }
+ }
+ }
+ }
+}
diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h
index b2d32cb475..ed2472f2fd 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.h
+++ b/libs/surfaces/mackie/mackie_control_protocol.h
@@ -21,6 +21,7 @@
#include <vector>
#include <map>
+#include <list>
#include <sys/time.h>
#include <pthread.h>
@@ -182,6 +183,22 @@ class MackieControlProtocol
void add_in_use_timeout (Mackie::Surface& surface, Mackie::Control& in_use_control, boost::weak_ptr<ARDOUR::AutomationControl> touched);
int modifier_state() const { return _modifier_state; }
+
+ void add_down_select_button (int surface, int strip);
+ void remove_down_select_button (int surface, int strip);
+ bool select_range ();
+
+ void add_down_solo_button (int surface, int strip);
+ void remove_down_solo_button (int surface, int strip);
+ bool solo_range ();
+
+ void add_down_mute_button (int surface, int strip);
+ void remove_down_mute_button (int surface, int strip);
+ bool mute_range ();
+
+ void add_down_recenable_button (int surface, int strip);
+ void remove_down_recenable_button (int surface, int strip);
+ bool recenable_range ();
protected:
// shut down the surface
@@ -286,6 +303,13 @@ class MackieControlProtocol
void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr);
/* BUTTON HANDLING */
+
+ std::list<uint32_t> _down_select_buttons;
+ std::list<uint32_t> _down_solo_buttons;
+ std::list<uint32_t> _down_mute_buttons;
+ std::list<uint32_t> _down_recenable_buttons;
+
+ void pull_route_range (std::list<uint32_t>& down, std::vector<boost::shared_ptr<ARDOUR::Route> >& selected);
/* implemented button handlers */
Mackie::LedState frm_left_press(Mackie::Button &);
diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc
index 88de3f1afc..aedd8548ec 100644
--- a/libs/surfaces/mackie/strip.cc
+++ b/libs/surfaces/mackie/strip.cc
@@ -291,8 +291,19 @@ Strip::notify_gain_changed (bool force_update)
} else {
_surface->write (_fader->set_position (pos));
}
- _last_gain_position_written = pos;
+ float dB = fast_coefficient_to_dB (pos);
+ if (pos == 0.0) {
+ _surface->write (display (1, " 0.0"));
+ } else {
+ char buf[16];
+
+ snprintf (buf, sizeof (buf), "%6.1f", dB);
+ _surface->write (display (1, buf));
+ }
+
+ _last_gain_position_written = pos;
+
} else {
DEBUG_TRACE (DEBUG::MackieControl, "value is stale, no message sent\n");
}
@@ -370,10 +381,6 @@ Strip::handle_button (Button& button, ButtonState bs)
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 handling button %2\n", _index, button.id()));
- if (bs != press) {
- return;
- }
-
int lock_mod = (MackieControlProtocol::MODIFIER_CONTROL|MackieControlProtocol::MODIFIER_SHIFT);
int ms = _surface->mcp().modifier_state();
bool modified = (ms & MackieControlProtocol::MODIFIER_CONTROL);
@@ -383,13 +390,16 @@ Strip::handle_button (Button& button, ButtonState bs)
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("select touch, lock ? %1\n", ((ms & lock_mod) == lock_mod) ? 1 : 0));
- if ((ms & lock_mod) == lock_mod) {
- _controls_locked = !_controls_locked;
- return;
- }
-
- if (_route) {
- _surface->mcp().select_track (_route);
+ if (bs == press) {
+
+ if ((ms & lock_mod) == lock_mod) {
+ _controls_locked = !_controls_locked;
+ return;
+ }
+
+ if (_route) {
+ _surface->mcp().select_track (_route);
+ }
}
return;
@@ -409,6 +419,11 @@ Strip::handle_button (Button& button, ButtonState bs)
_surface->mcp().add_in_use_timeout (*_surface, *_fader, _fader->control (modified));
}
+ if (bs != press) {
+ /* fader touch ended, revert back to label display for fader */
+ _surface->write (display (1, static_display_string()));
+ }
+
return;
}
@@ -586,6 +601,16 @@ Strip::gui_selection_changed (ARDOUR::RouteNotificationListPtr rl)
return _select->set_state (off);
}
+string
+Strip::static_display_string () const
+{
+ if (_surface->mcp().flip_mode()) {
+ return "Pan";
+ } else {
+ return "Fader";
+ }
+}
+
void
Strip::flip_mode_changed (bool notify)
{
@@ -604,7 +629,7 @@ Strip::flip_mode_changed (bool notify)
_vpot->set_normal_control (_route->gain_control());
_vpot->set_modified_control (boost::shared_ptr<AutomationControl>());
- _surface->write (display (1, "Fader"));
+ _surface->write (display (1, static_display_string ()));
} else {
@@ -615,7 +640,7 @@ Strip::flip_mode_changed (bool notify)
_fader->set_normal_control (_route->gain_control());
_fader->set_modified_control (boost::shared_ptr<AutomationControl>());
- _surface->write (display (1, "Pan"));
+ _surface->write (display (1, static_display_string()));
}
if (notify) {
diff --git a/libs/surfaces/mackie/strip.h b/libs/surfaces/mackie/strip.h
index 63682f5781..ca9862c6e3 100644
--- a/libs/surfaces/mackie/strip.h
+++ b/libs/surfaces/mackie/strip.h
@@ -107,6 +107,8 @@ private:
void update_automation ();
void update_meter ();
+
+ std::string static_display_string () const;
};
}