13
0

MCP: actually map routes to strips, more debug tracing

git-svn-id: svn://localhost/ardour2/branches/3.0@11865 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-10 15:13:37 +00:00
parent 342a78c9a3
commit 43a6662357
4 changed files with 43 additions and 20 deletions

View File

@ -235,15 +235,19 @@ MackieControlProtocol::n_strips() const
void
MackieControlProtocol::switch_banks (uint32_t initial, bool force)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch banking to start at %1 force ? %2 current = %3\n", initial, force, _current_initial_bank));
if (initial == _current_initial_bank && !force) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("not switching to %1\n", initial));
return;
}
Sorted sorted = get_sorted_routes();
uint32_t strip_cnt = n_strips();
if (sorted.size() <= strip_cnt) {
if (sorted.size() <= strip_cnt && !force) {
/* no banking */
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("not switching to %1\n", initial));
return;
}
@ -265,34 +269,26 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
if (_current_initial_bank <= sorted.size()) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2\n", _current_initial_bank, strip_cnt));
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2, available routes %3\n", _current_initial_bank, strip_cnt, sorted.size()));
// link routes to strips
Surfaces::iterator si = surfaces.begin();
uint32_t surface_strip_cnt = (*si)->n_strips();
uint32_t surface_strip = 0;
Sorted::iterator r = sorted.begin() + _current_initial_bank;
for (Sorted::iterator r = sorted.begin() + _current_initial_bank; r != sorted.end(); ++r) {
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
vector<boost::shared_ptr<Route> > routes;
uint32_t added = 0;
Strip* strip = (*si)->nth_strip (surface_strip);
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface has %1 strips\n", (*si)->n_strips()));
if (strip) {
strip->set_route (*r);
for (; r != sorted.end() && added < (*si)->n_strips(); ++r, ++added) {
routes.push_back (*r);
cerr << "\t\tadded " << (*r)->name() << endl;
}
if (surface_strip == surface_strip_cnt) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("give surface %1 routes\n", routes.size()));
/* move to next surface */
surface_strip = 0;
++si;
if (si == surfaces.end()) {
break;
}
surface_strip_cnt += (*si)->n_strips();
}
(*si)->map_routes (routes);
}
}

View File

@ -231,6 +231,10 @@ Strip::set_route (boost::shared_ptr<Route> r)
_route = r;
if (r) {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 strip %2 now mapping route %3\n",
_surface->number(), _index, _route->name()));
if (has_solo()) {
_route->solo_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_solo_changed, this), midi_ui_context());
@ -269,6 +273,9 @@ Strip::set_route (boost::shared_ptr<Route> r)
/* Update */
notify_all ();
} else {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 strip %2 now unmapped\n",
_surface->number(), _index));
}
}

View File

@ -606,3 +606,17 @@ Surface::jog_wheel_state_display (JogWheel::State state)
}
}
void
Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes)
{
vector<boost::shared_ptr<Route> >::const_iterator r;
Strips::iterator s;
for (s = strips.begin(); s != strips.end(); ++s) {
(*s)->set_route (boost::shared_ptr<Route>());
}
for (r = routes.begin(), s = strips.begin(); r != routes.end() && s != strips.end(); ++r, ++s) {
(*s)->set_route (*r);
}
}

View File

@ -14,6 +14,10 @@ namespace MIDI {
class Parser;
}
namespace ARDOUR {
class Route;
}
class MidiByteArray;
class MackieControlProtocol;
@ -74,6 +78,8 @@ public:
SurfacePort& port() const { return *_port; }
void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
const MidiByteArray& sysex_hdr() const;
void periodic ();